exists

以前都用in很少用exists.因为不理解为什么在exists后面写select..

其实就是在任何地方都可以写子查询

用到的表:

 

--in
select * from r_rank where rid in(
select stu_id from r_class_info)

改为:

select * from r_rank a where exists (select 1 from r_class_info b where a.rid = b.stu_id)

  

posted @ 2018-12-16 17:11  圣金巫灵  阅读(232)  评论(0编辑  收藏  举报