How can we find records based on whether related transactions exist?
EXISTS evaluates to true if the subquery returns at least one matching row.
Finding customers with purchases, auditing orphan records with NOT EXISTS.
SELECT c.customer_name
FROM customers c
WHERE EXISTS (
SELECT 1
FROM orders o
WHERE o.customer_id = c.customer_id
);Practice typing production-grade SQL code for EXISTS & NOT EXISTS.