The EXISTS condition tests whether a specified row exists in a subquery.
Syntax
The syntax of the EXISTS condition is as follows:
EXISTS (subquery)
If the subquery returns at least one row, the data you want exists.
Examples
SELECT dept_id FROM dept d WHERE EXISTS (SELECT * FROM emp e
WHERE d.dept_id = e.dept_id) ORDER BY dept_id;
