MySQL LEFT JOIN语法错误

时间:2012-10-18 09:25:27

标签: mysql sql syntax left-join

快速提问,只是想知道是否有人可以看到LEFT JOIN中语法错误的位置?

SELECT
...
FROM table1 AS t1, table2 AS t2, table3 AS s3
table4 AS t4, table5 AS t5 LEFT JOIN table6 AS t6 ON t5.id = t6.t5_id
AND t6.etc
ORDER BY ...

我只能假设它不喜欢t1,t2,t3,t4LEFT JOIN之前的t5 & t6

错误说明

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 'table4 AS t4, table5 AS t5  LEFT JOIN table6 AS t6 ON ON t5.id = t6' at line 26*

6 个答案:

答案 0 :(得分:3)

在table3 AS s3之后加上逗号

table3 AS s3,

答案 1 :(得分:3)

table3 as s3

后面没有逗号“,”
table3 as s3,

答案 2 :(得分:0)

查询应该是这样的,您在table3 AS s3,

附近错过了逗号
SELECT
...
FROM table1 AS t1, table2 AS t2, table3 AS s3,
table4 AS t4, table5 AS t5 LEFT JOIN table6 AS t6 ON t5.id = t6.t5_id
AND t6.etc
ORDER BY ...

如果错了,请纠正我

答案 3 :(得分:0)

如前所述,在“table3 AS s3”后面加一个逗号:

table3 AS s3,

以及完成表达“AND t6.etc”,例如:

AND t6.etc = 1

或使用WHERE子句,例如:

WHERE t6.etc = 1

HTH(Y)

答案 4 :(得分:0)

请参阅以下博客,并附上您的问题答案和语法示例: Here

答案 5 :(得分:0)

SELECT * FROM t1 LEFT JOIN (t2, t3, t4)
                 ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)