1

快速提问,只是想知道是否有人可以看到语法错误在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,t4前面LEFT JOINt5 & 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*
4

6 回答 6

4

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

table3 as s3,
于 2012-10-18T09:27:23.577 回答
3

在 table3 AS s3 后面加逗号

table3 AS s3,
于 2012-10-18T09:27:19.873 回答
1
SELECT * FROM t1 LEFT JOIN (t2, t3, t4)
                 ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)
于 2012-10-18T09:43:08.360 回答
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 ...

如果错了请纠正我

于 2012-10-18T09:29:30.837 回答
0

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

table3 AS s3,

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

AND t6.etc = 1

或使用 WHERE 子句,例如:

WHERE t6.etc = 1

HTH (Y)

于 2012-10-18T09:33:31.327 回答
0

请参考以下博客,附上您的问题答案和语法示例: 这里

于 2012-10-18T09:39:33.460 回答