How do you find rows in one table that have no match in another?
Model answer
LEFT JOIN and filter for NULL on the right key: SELECT c.* FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL. Alternatively use NOT EXISTS, which is often just as fast and clear.
Learn this topic
SQL JOINs: INNER JOIN and LEFT JOIN Explained in the course SQL for Beginners: Learn Databases Step by Step.
Sign in to add your own answer.