Main Table : MT
===============
PK, C1, C2
==========
1, X, X
2, X, X
3, X, X
..........
100, X, X
Table 1 :T1
===============
PK, TC1
=======
2, D1
3, D1
Table 2: T2
===============
PK, TC2
=======
3, D2
Table 3: T3
===============
PK, TC3
=======
4, D3
Table 4: T4
===============
PK, TC4
=======
2, D4
在进行一些连接或任何方式后,我想要主表的输出,如下所示:
Master Table
===============
PK,C1,C2,TC1,TC2,TC3,TC4
========================
(1,X,X,null,null,null,null)
(2,X,X,D1,null,null,D4)
(3,X,X,D1,D2,null,null)
(4,X,X,null,null,D3,null)
我试过了
select * from
MT inner join T1 on MT.PK=T1.PK
inner join T2 on MT.PK = T2.PK
inner join T2 on MT.PK = T3.PK
inner join T2 on MT.PK = T4.PK
但是我得到了一些重复的行。即使尝试了不同的仍然会重复。我认为必须有其他选择来实现这一目标。