gpt4 book ai didi

mysql - 在 MySQL 中使用 EXCEPT 时的并发症

转载 作者:行者123 更新时间:2023-11-29 13:31:11 25 4
gpt4 key购买 nike

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

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

表“orders”包含 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

最佳答案

试试这个::

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

关于mysql - 在 MySQL 中使用 EXCEPT 时的并发症,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19433911/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com