exists

Posted dayanjing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)

  

以上是关于exists的主要内容,如果未能解决你的问题,请参考以下文章