内在join三张桌子
我有三个表,我希望内部join他们之间的共同列。
说我的桌子是;
TableA TableB TableC
我希望joinAB
,但是BC
也都是由这个共同的领域所共同的。
我已经join了两张这样的桌子;
dbo.tableA AS A INNER JOIN dbo.TableB AS B ON A.common = B.common
我如何添加第三个?
select * from tableA a inner join tableB 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
dbo.tableA AS A INNER JOIN dbo.TableB AS B ON A.common = B.common INNER JOIN TableC C ON B.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