ORACLE 子查询 嵌套查询 多值子查询


用exist 当作布尔值来处理,当查询语句有结果时 返回true, 否则返回false.

1 select * from emp where exists (select * from emp where neo=123);
1     --查询有员工的部门的信息
2 
3     select * from dept d1 where exists(select * from emp e1 where e1.deptno = d1.deptno );
1     --查询不是领导的信息(含null值正确写法)
2 
3     select * from emp where empno not in (select mgr from emp where mgr is not null); --查询出8条记录


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM