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