All Products
Search
Document Center

EXISTS conditions

Last Updated: Jun 18, 2021

An EXISTS condition tests whether a specified row exists in a subquery.

Syntax

EXISTS (subquery)

If a subquery returns at least one row, your required data exists.

Examples

SELECT department_id FROM departments d WHERE EXISTS (SELECT * FROM employees e 
WHERE d.department_id = e.department_id) ORDER BY department_id;