注册 登录
编程论坛 SQL Server论坛

查询select问题

hksyw 发布于 2011-01-07 15:31, 940 次点击
select * from a where code=等于的条件在另一个表里

这个怎样写呀
4 回复
#2
hksyw2011-01-07 17:29
版大
请指教呀
#3
wlsirone2011-01-07 19:47
select * from a where code in
(select code from b)
说的具体点,你的条件是查询什么?
#4
jianghong_022011-01-09 22:36
也可以用内联方法
#5
juejitianya2011-01-10 14:07
select * from t1
where exists(select * from t2 where t1.code=t2.code)
--where code = any (select code from t2)
--
where code in (select code from t2)
上述三种where条件应该都可以满足楼主的要求,其中使用in语句时,效率低一些。
它们三个之间详细的对比在百度中有大量的解释,可以去查查。
1