Exists clause: – The exists clause is used for testing whether the given set is empty or not. Exists on empty set return false while on non-empty set it returns true. The exists clause is used with where condition. An example of exists clause is –

                Select emp1.ename from employee emp1 where exists(select emp2.city from company emp2 where emp2.ename=‘Anil’ and emp1.city=emp2.city);

In case of above example, ename column value of table employee are listed only when living city of both tables employee and company are same as living city of employee ‘Anil’.

Advertisements