thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Intermediate

EXISTS Operator

A predicate that returns true if a subquery returns at least one row.

Definition

EXISTS checks only for existence, so the subquery's select list is irrelevant (SELECT 1 is customary). It is typically used with correlated subqueries and short-circuits on the first match.

Example

SELECT * FROM Products p WHERE EXISTS (SELECT 1 FROM OrderLines l WHERE l.ProductID = p.ProductID);

Exam tip

EXISTS returns TRUE or FALSE, never UNKNOWN, so it is unaffected by NULLs.

Related terms