内部连接三个表

我有三个表,我希望通过它们之间的公共列在内部联接。

假设我的桌子是

TableA TableB TableC

我希望加入 A-B,然后也 B-C所有由这个共同领域我将调用共同。

我加入了两张这样的桌子;

dbo.tableA AS A INNER JOIN dbo.TableB AS B
ON A.common = B.common

第三个怎么加?

232425 次浏览
select *
from
tableA a
inner join
tableB b
on a.common = b.common
inner join
TableC c
on b.common = c.common
dbo.tableA AS A INNER JOIN dbo.TableB AS B
ON A.common = B.common INNER JOIN TableC C
ON B.common = C.common

再做同样的事情,但是对于 TableC

SELECT *
FROM dbo.tableA A
INNER JOIN dbo.TableB B ON A.common = B.common
INNER JOIN dbo.TableC C ON A.common = C.common

尝试下面的代码

select * from TableA A
inner join TableB B on A.Column=B.Column
inner join TableC C on A.Column=C.Column

试试这个:

SELECT * FROM TableA
JOIN TableB ON TableA.primary_key = TableB.foreign_key
JOIN TableB ON TableB.foreign_key = TableC.foreign_key