select * from T1 where id=(select id from T2 where s1='test') select * from T1 right join T2 on T1.id=T2.id where T2.s1='test'
--你的已經很精簡了 select a.* from T1 a,T2 b where a.id=b.id and b.s1='test'
select * from T1 inner join T2 on T1.id=T2.id where T2.s1='test' 其实楼主的语句也能实现您想要的功能呀.只是楼主的是嵌套查询罢了.
(1)select * from T1 right join T2 on T1.id=T2.id where T2.s1='test'(2)select a.* from T1 a,T2 b where a.id=b.id and b.s1='test' (3)select * from T1 where id in (select id from T2 where s1='test')
select a.* from T1 a,T2 b where a.id=b.id and b.s1='test'
select t1.* from t1 join t2 on t1.id=t2.id and t2.s1='test'--直接連接
本帖最后由 fcuandy 于 2008-11-07 10:05:39 编辑
select distinct a.* from t1 a,t2 b where a.id = b.id and b.s1='test'
select * from T1
where id=(select id from T2 where s1='test')
select * from T1 right join T2 on T1.id=T2.id
where T2.s1='test'
select a.* from T1 a,T2 b where a.id=b.id and b.s1='test'
from T1
inner join T2
on T1.id=T2.id
where T2.s1='test'
其实楼主的语句也能实现您想要的功能呀.只是楼主的是嵌套查询罢了.
where T2.s1='test'(2)select a.* from T1 a,T2 b where a.id=b.id and b.s1='test'
(3)select * from T1
where id in (select id from T2 where s1='test')
select distinct a.* from t1 a,t2 b where a.id = b.id and b.s1='test'