TableA:
+------+------+---------+
| A_Id | B_Id | AValue |
+------+------+---------+
TableB:
+------+------+------+
| B_Id | A_Id | C_Id |
+------+------+------+
TableC:
+------+------+------+---------+
| C_Id | B_Id | D_Id | CValue |
+------+------+------+---------+
TableD:
+------+---------+
| D_Id | DValue |
+------+---------+
SELECT AValue, CValue, Dvalue
FROM TableA
inner JOIN TableB
ON TableA.A_Id = TableB.A_Id
inner JOIN TableC
ON TableB.B_Id=TableC.B_Id;
inner JOIN TableD
ON TableC.D_Id=TableD.D_Id;
然而,这并不是我需要的DValue列,只有AValue和CValue列。我需要所有三列。我怎么会这样做?
答案 0 :(得分:0)
列键中有一些不合逻辑的东西。 TableC和TableB包含3个映射键...虽然我不知道它们代表什么,但其中一些没有映射,也许你想尝试
SELECT AValue, CValue, Dvalue
FROM TableA
inner JOIN TableB using(B_Id)
inner JOIN TableC using(C_Id)
inner JOIN TableD using(D_Id)