不确定如何从查询的一部分写

时间:2014-02-11 00:44:21

标签: sql

我的任务是写一个查询来提取以下内容:

2013年12月18日创建的广告商输入的订单。

到目前为止我有这个,但我错过了FROM篇。

Select 
     WO_STATIONS.station_call_letters as "Station"
     ,WO_ORDERS.ORDER_NUMBER as "Order"
     ,WO_ADVERTISERS.advertiser_name as "Advertiser"
     ,WO ADVERTISERS.TCODE as "Adv Num"
     ,WO_ORDERS.FLIGHT_START_DATE as "Order Start"
     ,WO_ORDERS.FLIGHT_END_DATE as "Order End"
     ,WO_ADVERTISERS.CREATE_DATE AS "ADV CREATED"

FROM 

WHERE
      WO_ADVERTISERS.CREATE_DATE > '12/18/2013'

1 个答案:

答案 0 :(得分:0)

看起来可能有点像这样:

Select 
     WO_STATIONS.station_call_letters as "Station"
     ,WO_ORDERS.ORDER_NUMBER as "Order"
     ,WO_ADVERTISERS.advertiser_name as "Advertiser"
     ,WO ADVERTISERS.TCODE as "Adv Num"
     ,WO_ORDERS.FLIGHT_START_DATE as "Order Start"
     ,WO_ORDERS.FLIGHT_END_DATE as "Order End"
     ,WO_ADVERTISERS.CREATE_DATE AS "ADV CREATED"

FROM 
     WO_ORDERS inner join WO_STATIONS on WO_ORDERS.StationId = WO_STATIONS.StationId
     inner join WO_ADVERTISERS on WO_ADERTISERS.AdvertiserId = WO_ORDERS.AdververtiserId
WHERE
      WO_ADVERTISERS.CREATE_DATE > '12/18/2013'

您的数据库工具是否具有用于构建查询或视图的图形用户界面?如果是这样,您可以将三个表添加到查询工具中。如果数据库具有外键,则工具将自动为您创建FROM子句。如果没有,您可以将一个表的主键拖放到另一个表的外键中。

尝试使用这些资源获取有关连接的更多信息: Access SQL

我还推荐一本关于SQL的好书,例如:SQL Step by Step