我想参加内部加入并得到以下错误:
#1064-您的SQL语法有误;检查与您的MySQL服务器版本相对应的手册,以在第7行“ INNER JOIN(SELECT Chalanits.Chalanit_partno,Chalanits.Chalanit_qty FROM Chala'')附近使用正确的语法
SELECT Cuspoit.`Cuspoit_partno`, Cuspoit.`Cuspoit_unitprice`, Chalanits.Chalanit_qty
FROM Cuspoit
WHERE Cuspoit.`Cuspoit_cuspoid` =
(
SELECT Chalanits.Chalanit_cuspoid FROM Chalanits WHERE Chalanits.Chalanit_chalanid='CX-1306001' LIMIT 1
)
INNER JOIN (
SELECT Chalanits.Chalanit_partno, Chalanits.Chalanit_qty
FROM Chalanits
WHERE Chalanits.Chalanit_chalanid='CX-1306001')
ON Cuspoit.`Cuspoit_partno`= Chalanits.Chalanit_partno
谁能帮我找到错误?
最佳答案
使用该SQL:
SELECT Cuspoit.`Cuspoit_partno`, Cuspoit.`Cuspoit_unitprice`, Chalanits.Chalanit_qty
FROM Cuspoit
INNER JOIN (
SELECT Chalanits.Chalanit_partno, Chalanits.Chalanit_qty
FROM Chalanits
WHERE Chalanits.Chalanit_chalanid='CX-1306001')
ON Cuspoit.`Cuspoit_partno`= Chalanits.Chalanit_partno
WHERE Cuspoit.`Cuspoit_cuspoid` =
(
SELECT Chalanits.Chalanit_cuspoid FROM Chalanits WHERE Chalanits.Chalanit_chalanid='CX- 1306001' LIMIT 1
)
您已经颠倒了WHERE和THE INNER JOIN命令