Naan
Naan

Reputation: 541

Complications while using EXCEPT in MySQL

I'm trying to select CustomerID that didn't ordered in year 1977 with:

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

the table 'orders' contains both CustomerID and OrderDate

The error is:

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

Upvotes: 0

Views: 515

Answers (1)

Sashi Kant
Sashi Kant

Reputation: 13465

Try this::

SELECT CustomerID FROM orders WHERE YEAR(OrderDate)<>1977;

Upvotes: 1

Related Questions