请参阅以下SQL ..
SELECT t1.*
FROM table1 t1
INNER JOIN table2 t2 ON t1.user_id = t2.id, tables3 t3
WHERE t3.id = 999
这里有什么样的联接?在t1和t3之间?我的意思是逗号是什么?
答案 0 :(得分:4)
,
子句中的FROM
是CROSS JOIN
编写查询的更好方法是使用显式CROSS JOIN
:
SELECT t1.*
FROM table1 t1 INNER JOIN
table2 t2
ON t1.user_id = t2.id CROSS JOIN
tables3 t3
WHERE t3.id = 999 ;
如上所述,查询毫无意义。假设t3.id = 999
为真且出现一次,那么这相当于:
SELECT t1.*
FROM table1 t1 INNER JOIN
table2 t2
ON t1.user_id = t2.id;
如果该值不存在,则不会返回任何行。
答案 1 :(得分:-1)
SELECT t1.*
FROM table1 t1
JOIN table2 t2 ON t1.user_id = t2.id
JOIN tables3 t3 ON t2.id=t3.id
WHERE t3.id = 999