EXISTS
An operator that is true when a subquery returns at least one row, whatever the row contains.
In more detail
It stops looking at the first match, so it is cheap. NOT EXISTS is the safe way to ask for rows with no match, because unlike NOT IN it is not confused by NULLs.
Related terms
- correlated subquery — A subquery that refers to a column of the outer query's current row, so its answer differs row by row.
- anti join — A query that returns the rows of one table that have no matching row in another, such as products nobody has ordered.
- IN — An operator that is true when a value equals any value in a list or in the rows a subquery returns.
Taught in
- Subqueries — PostgreSQL, Indexing & Relational Data Modeling