The EXISTS condition is used to check for specified rows in a subquery.
Syntax
The syntax of the EXISTS condition is as follows:
EXISTS (subquery)
If at least one row is returned by the subquery, 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;