日期:2014-05-18  浏览次数:20450 次

这个语句怎么写 ?速揭贴~高手COME
表1
ID         T1
1           A
2           B
3           C
表2
ID       Copy_T3       Copy_T1
1         D                   A
2         E                   B
3         F                   C
4         D                   B
5         D                   C
6         E                   C
表3
ID       T3      
1         D
2         E
3         F

如何知道表3里的D   查询关联的表1里有什么?LOOP?怎么个写法?或好点的办法~

------解决方案--------------------
select a.* from 表1 a,表2 b,表3 c where a.T1=b.Copy_T1 and b.Copy_T3=c.T3 and c.T3= 'D '
------解决方案--------------------
select * from table1 a join (select * from table2 where Copy_T3= 'd ')b on a.t1=b.Copy_T1
------解决方案--------------------
--和表3没关系了?
select 表1.* from 表1 where 表1.t1 in (select 表2.Copy_T1 from 表2 where copy3_t3 = 'D ')