AI engineering glossary · SQL databases

What is EXISTS?

EXISTS: A predicate that is true when its subquery returns at least one row. It stops at the first match, so it is efficient for checking presence, and it is safe with NULL, unlike NOT IN.

Level: intermediateTopic: SQL databases

EXISTS: an example

WHERE EXISTS (SELECT 1 FROM orders o WHERE o.customer_id = c.id) keeps customers who have placed an order.

Related terms

More SQL databases terms

Where you learn it

EXISTS is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.