gpt4 book ai didi

mysql - MySQL 高级查询代码 1064 出错

转载 作者:行者123 更新时间:2023-11-29 17:33:50 26 4
gpt4 key购买 nike

当我尝试执行以下查询时,我不断收到错误:

SELECT C.CustomerID WITH C.CustomerName WITH O.OrderDate WITH O.TotalOrderAmount
FROM CUSTOMERS C
LEFT JOIN [ORDERS] 0
ON C.CustomerID=O.CustomerID

UNION

SELECT C.CustomerID, C.CustomerName, O.OrderDate, O.TotalOrderAmount
FROM CUSTOMERS C
RIGHT JOIN [ORDERS] 0
On C.CustomerID-O.CustomerID;

下面是我在 MySQL 中收到的代码:

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 '[ORDERS] 0 ON C.CustomerID=O.CustomerID  UNION  SELECT C.CustomerID, C.CustomerN' at line 3

非常感谢您为纠正此错误提供的任何帮助。

最佳答案

只需执行完全连接而不是并集。应该在这里给你相同的结果:

SELECT C.CustomerID, C.CustomerName, O.OrderDate, O.TotalOrderAmount
FROM CUSTOMERS C
full JOIN [ORDERS] 0
On C.CustomerID-O.CustomerID

关于mysql - MySQL 高级查询代码 1064 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50456200/

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