0

我正在尝试选择 1977 年未订购的 CustomerID:

SELECT CustomerID 
FROM orders
EXCEPT 
SELECT CustomerID 
FROM orders 
WHERE YEAR(OrderDate)=1977);

表“订单”同时包含 CustomerID 和 OrderDate

错误是:

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT CustomerID FROM orders WHERE YEAR(OrderDate)=1977)' at line 1
4

1 回答 1

1

试试这个::

SELECT CustomerID FROM orders WHERE YEAR(OrderDate)<>1977;
于 2013-10-17T18:01:04.560 回答