Bird
0
0

Which of the following SQL queries correctly finds customers without orders using LEFT JOIN?

easy📝 Syntax Q12 of 15
SQL - LEFT and RIGHT JOIN
Which of the following SQL queries correctly finds customers without orders using LEFT JOIN?
ASELECT c.id FROM customers c RIGHT JOIN orders o ON c.id = o.customer_id WHERE c.id IS NULL;
BSELECT c.id FROM customers c INNER JOIN orders o ON c.id = o.customer_id WHERE o.customer_id IS NULL;
CSELECT c.id FROM customers c LEFT JOIN orders o ON c.id = o.customer_id WHERE c.id IS NULL;
DSELECT c.id FROM customers c LEFT JOIN orders o ON c.id = o.customer_id WHERE o.customer_id IS NULL;
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct JOIN type

    LEFT JOIN keeps all customers and matches orders; unmatched orders will be NULL.
  2. Step 2: Filter unmatched orders

    WHERE o.customer_id IS NULL selects customers without orders.
  3. Final Answer:

    SELECT c.id FROM customers c LEFT JOIN orders o ON c.id = o.customer_id WHERE o.customer_id IS NULL; -> Option D
  4. Quick Check:

    LEFT JOIN + right table NULL = unmatched left rows [OK]
Quick Trick: Use LEFT JOIN and check right table key IS NULL [OK]
Common Mistakes:
MISTAKES
  • Using INNER JOIN which excludes unmatched rows
  • Checking NULL on left table columns
  • Using RIGHT JOIN incorrectly for this case

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes