select * from sc where cno='c001' and sno in(select sno from sc where cno='c002'); select * from sc where cno='c001' and exists(select sno from sc where cno='c002'); 请问这两句运行结果为什么不一样?
2013-09-11 20:41
提问者采纳
是这样的 in 是返回的结果集 比如你只运行这一句 select sno from sc where cno='c002' 返回的是一列sno 但是exists则不同,返回的是布尔值 虽然里边那个没法单独运行 select * from sc a where cno='c001' and exists(select sno from sc b where cno='c002' and a.sno=b.sno) ; 后边必须要写上两者的关联