我有以下查詢....不能讓我的SQL查詢,以符合最新要求
SELECT DISTINCT
p.ProductID, p.ProductName,
od.Quantity, o.Shipcountry, o.ShippedDate
FROM
Products p, [Order Details] od, Orders o
WHERE
p.ProductID = od.ProductID
AND od.OrderID = o.OrderID
AND o.ShippedDate < '1997-01-01'
AND ShipCountry = 'Spain'
OR ShipCountry = 'Portugal'
ORDER BY
p.ProductName ASC
我試圖讓所有訂單按時發貨之前輸入的日期,但它不似乎工作......在所有的,下面是從查詢
82 Alice Mutton 91 Portugal 1996-10-17 00:00:00.000
82 Alice Mutton 110 Portugal 1997-03-04 00:00:00.000
17 Alice Mutton 21 Portugal 1996-11-18 00:00:00.000
82 Alice Mutton 4 Portugal 1997-03-04 00:00:00.000
17 Alice Mutton 28 Portugal 1998-04-13 00:00:00.000
82 Alice Mutton 130 Portugal 1997-04-08 00:00:00.000
17 Alice Mutton 10 Portugal 1996-10-25 00:00:00.000
82 Alice Mutton 22 Portugal 1996-10-25 00:00:00.000
17 Alice Mutton 1 Portugal 1997-06-06 00:00:00.000
17 Alice Mutton 36 Portugal 1998-03-26 00:00:00.000
82 Alice Mutton 49 Portugal 1997-01-02 00:00:00.000
82 Alice Mutton 66 Portugal 1997-07-29 00:00:00.000
82 Alice Mutton 39 Portugal 1997-01-02 00:00:00.000
82 Alice Mutton 120 Portugal 1997-04-08 00:00:00.000
你的問題被標記的MySQL但您使用方括號,這是指示性的SQL Server或Sybase的。你真的在使用哪個數據庫? – 2014-09-26 02:22:34
我的合同...其SQL Server – Jeremy 2014-09-26 02:26:46
[踢壞的習慣:使用舊式JOIN](http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick -using-old-style-joins.aspx) - 在ANSI-** 92 ** SQL標準(*)中,舊式*逗號分隔的表*樣式列表已替換爲* proper * ANSI'JOIN'語法*超過20年**),其使用不鼓勵 – 2014-09-26 05:30:54