EXISTS Predicate

noun

say it: “ig-ZISTS PRED-ih-kit” /ɪɡˈzɪsts ˈprɛdɪkɪt/

A SQL condition that is true when its subquery returns at least one row.

What does EXISTS Predicate do in a relational database?

EXISTS Predicate — A predicate that is true when its subquery returns at least one row.

SELECT customer_id
FROM customer
WHERE EXISTS (
    SELECT 1
    FROM purchase_order
    WHERE purchase_order.customer_id = customer.customer_id
);

In a sentence

  • “WHERE EXISTS (SELECT 1 FROM Orders ...) keeps only customers who have ordered.”

Level: Apprentice · More SQL terms at this level

Updated