SQL Joining Multiple Tables 3 — Questions and Answers
Question 1: To find customers who have NEVER placed an order, you LEFT JOIN Orders and then filter how?
- WHERE Orders.id IS NULL (Correct answer)
- WHERE Orders.id = 0
- WHERE Orders.id != NULL
- HAVING COUNT(*) = 0
Correct answer: WHERE Orders.id IS NULL
Unmatched rows have NULL in the order columns, so IS NULL isolates them.
Question 2: When joining three tables A, B, and C, how many ON conditions are typically needed?
- Two (Correct answer)
- One
- Three
- Zero
Correct answer: Two
Each additional joined table generally needs one more ON condition to link it.
Question 3: Which comparison is INVALID for matching NULLs in a join condition?
- column = NULL (Correct answer)
- column IS NULL
- column IS NOT NULL
- COALESCE(column, 0) = 0
Correct answer: column = NULL
NULL is never equal to anything, so '= NULL' never matches; use IS NULL.
Question 4: A RIGHT JOIN of Employees and Departments keeps all rows from which table?
- Departments (Correct answer)
- Employees
- Both equally
- Neither
Correct answer: Departments
RIGHT JOIN preserves all rows from the right (second) table, Departments.
Question 5: Why are table aliases especially useful in multi-table joins?
- They shorten references and disambiguate same-named columns (Correct answer)
- They speed up the query engine
- They are required by SQL syntax
- They create indexes automatically
Correct answer: They shorten references and disambiguate same-named columns
Aliases make queries readable and resolve ambiguity when columns share names.
Question 6: Placing a filter on the right table in the WHERE clause of a LEFT JOIN can have what effect?
- It can turn the LEFT JOIN into an effective INNER JOIN (Correct answer)
- It speeds the join up
- It has no effect
- It causes a syntax error
Correct answer: It can turn the LEFT JOIN into an effective INNER JOIN
Filtering non-NULL right-table values in WHERE removes the NULL-padded unmatched rows.
Question 7: Which join would you use to list every product alongside its sales, including products with zero sales?
- LEFT JOIN with Products on the left (Correct answer)
- INNER JOIN
- CROSS JOIN
- RIGHT JOIN with Sales on the left
Correct answer: LEFT JOIN with Products on the left
A LEFT JOIN keeps all products and NULL-fills those without sales.
To find customers who have NEVER placed an order, you LEFT JOIN Orders and then filter how?