假设从表A中,我的帐户下有 EID (2,3,4),在表中BI希望显示所有记录其中DEP等于EID 。
谢谢,
表A
++++++++++++++++++++++++++
id | EID | EC |
++++++++++++++++++++++++++
1 | 2 | M +
2 | 2 | Y +
3 | 3 | S +
4 | 3 | Q +
5 | 4 | L +
6 | 5 | I +
++++++++++++++++++++++++++
表B
++++++++++++++++++++++++++
A | B | DEP |
++++++++++++++++++++++++++
1 | 2 | 2 +
2 | 2 | 2 +
3 | 3 | 3 +
4 | 3 | 3 +
5 | 4 | 4 +
6 | 5 | 5 +
++++++++++++++++++++++++++
这是我想要实现的输出。
++++++++++++++++++++++++++
Results |
++++++++++++++++++++++++++
1 | 2 | 2 +
2 | 2 | 2 +
3 | 3 | 3 +
4 | 3 | 3 +
5 | 4 | 4 +
++++++++++++++++++++++++++
答案 0 :(得分:0)
我的帐户下有EID(2,3,4)
select distinct B.A, B.B, A.EID
from TableB B
inner join TableA A on A.EID=B.DEP
where A.EID in (2,3,4)
<强> SQL FIDDLE 强>