Bird
0
0

Find the issue in this query:

medium📝 Debug Q7 of 15
SQL - Advanced Joins
Find the issue in this query:
SELECT * FROM orders o LEFT JOIN customers c ON o.customer_id = c.id WHERE c.id = 10;
AWHERE clause filters out unmatched rows, negating LEFT JOIN
BLEFT JOIN should be INNER JOIN for this filter
CMissing GROUP BY clause
DIncorrect table alias usage
Step-by-Step Solution
Solution:
  1. Step 1: Understand LEFT JOIN with WHERE filter

    WHERE c.id = 10 excludes rows where c.id is NULL, removing unmatched rows.
  2. Step 2: Effect on LEFT JOIN

    This negates the purpose of LEFT JOIN, which is to keep unmatched rows.
  3. Final Answer:

    WHERE clause filters out unmatched rows, negating LEFT JOIN -> Option A
  4. Quick Check:

    WHERE on joined table column removes unmatched rows [OK]
Quick Trick: WHERE on right table column after LEFT JOIN removes unmatched rows [OK]
Common Mistakes:
MISTAKES
  • Assuming LEFT JOIN always keeps unmatched rows
  • Ignoring WHERE clause effect
  • Confusing alias usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes