The predicate EXISTS will return true when the sub query return at least one row and otherwise is returns false
NOT EXISTS will return true when the sub query return no rows and otherwise is returns false
The below example display the details of emp to when at least one employee is reporting
Display the details of all departments in which there are no emps
NOT EXISTS will return true when the sub query return no rows and otherwise is returns false
The below example display the details of emp to when at least one employee is reporting
select *from emp M where EXISTS(select *from emp E where E.no=M.empno)
Display the details of all departments in which there are no emps
select *from dept where not exists(select *from emp e where e.deptno=d.deptno)
No comments:
Post a Comment