⌨ Programming Easy SQL Joins

Customers Who Never Placed an Order

Question

Find all customers who have never placed any order. Return their full name and email.

πŸ’‘ Use customers and orders tables.
SQL Editor
Solution
SELECT
  c.first_name || ' ' || c.last_name AS customer_name,
  c.email
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id
WHERE o.order_id IS NULL;
Explanation: LEFT JOIN ensures all customers appear. Filter WHERE order_id IS NULL keeps only those with no matching order β€” this is the ANTI JOIN pattern.