我最近试图提取一些结果,并且正在努力找出正确的查询来做到这一点。我见过的所有例子,甚至我的 MySQL 书都显示如下:
SELECT *
FROM table_1
LEFT JOIN table_2 LEFT OUTER JOIN table_3 LEFT JOIN table_2
ON table_1.id = table_2.rel_id
AND table_1.id = table_3.rel_id
AND table_3.id = table_2.rel_id
WHERE table_1.some_col = some_vale;
这不起作用,相反,解决方案是:
SELECT *
FROM table_1
LEFT JOIN table_2 ON table_1.id = table_2.rel_id
LEFT OUTER JOIN table_3 ON table_1.id = table_3.rel_id
LEFT JOIN table_2 ON table_3.id = table_2.rel_id
WHERE table_1.some_col = some_value;
SELECT
这两种说法有什么区别?什么时候应该使用每个?怎么做
你确定连接是如何工作的?