如何在 mysql 上的一个查询(3 个表)中进行 2 个不同的连接
How to make 2 different joins in one query (3 tables) on mysql
假设我有 3 个表,我想像这样加入它们:
table 1 join table 2 and table 2 join table 3
我正在尝试以下代码,但出现语法错误。
SELECT * from table1 join table2 and table2 join table3
on table1.id=table2.idA and table2.idB=table3.id
稍微研究一下 SQL。语法如下:
select *
from table1 join
table2
on table1.id = table2.idA join
table3
on table2.idB = table3.id;
这是非常基本的 JOIN
语法,任何教程、文档、书籍、论文或任何您用来学习 SQL.
的东西都应该包含这些内容
假设我有 3 个表,我想像这样加入它们:
table 1 join table 2 and table 2 join table 3
我正在尝试以下代码,但出现语法错误。
SELECT * from table1 join table2 and table2 join table3
on table1.id=table2.idA and table2.idB=table3.id
稍微研究一下 SQL。语法如下:
select *
from table1 join
table2
on table1.id = table2.idA join
table3
on table2.idB = table3.id;
这是非常基本的 JOIN
语法,任何教程、文档、书籍、论文或任何您用来学习 SQL.