Questions: SQL Joins

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

You want to find all customers who have never placed an order. You have a `customers` table and an `orders` table joined by `customer_id`. Which query correctly solves this?

ASELECT c.name FROM customers c INNER JOIN orders o ON c.id = o.customer_id WHERE o.id IS NULL
BSELECT c.name FROM customers c LEFT JOIN orders o ON c.id = o.customer_id WHERE o.id IS NULL
CSELECT c.name FROM customers c RIGHT JOIN orders o ON c.id = o.customer_id WHERE o.id IS NULL
DSELECT c.name FROM customers c INNER JOIN orders o ON c.id = o.customer_id WHERE o.customer_id IS NULL
Question 2 Multiple Choice

You add a filter condition `AND o.status = 'shipped'` to a LEFT JOIN query. Where you place this condition — in the ON clause versus the WHERE clause — produces different results. Which statement correctly explains why?

AON and WHERE are aliases in SQL; the query planner treats them identically for LEFT JOINs
BA condition in ON filters before rows are returned, while WHERE filters after, but the final row count is the same because SQL optimizes both paths
CA condition in ON filters during the join, so unmatched rows still appear with NULLs; a condition in WHERE filters after the join, removing those NULL rows and converting the LEFT JOIN to an INNER JOIN
DConditions belong in WHERE for correctness; ON should only contain the primary key match
Question 3 True / False

A LEFT JOIN query that returns no rows from the left table proves that no rows in the left table matched the join condition.

TTrue
FFalse
Question 4 True / False

LEFT JOIN and RIGHT JOIN are functionally identical; you can always rewrite one as the other by swapping the order of the two tables.

TTrue
FFalse
Question 5 Short Answer

Explain the critical difference between placing a filter condition in the ON clause versus the WHERE clause of an outer (LEFT/RIGHT) JOIN query, and give an example of where getting this wrong would produce a silently incorrect result.

Think about your answer, then reveal below.