Skip to main content
Skip to main content
Edit this page

EXISTS

The EXISTS operator checks how many records are in the result of a subquery. If it is empty, then the operator returns 0. Otherwise, it returns 1.

EXISTS can also be used in a WHERE clause.

Tip

References to main query tables and columns are not supported in a subquery.

Syntax

Example

Query checking existence of values in a subquery:

Result:

Query with a subquery returning several rows:

Result:

Query with a subquery that returns an empty result:

Result: