Вопрос

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
Это было полезно?

Решение

Try this::

SELECT CustomerID FROM orders WHERE YEAR(OrderDate)<>1977;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top