Bird
0
0

You wrote this query:

medium📝 Debug Q6 of 15
SQL - LEFT and RIGHT JOIN
You wrote this query:
SELECT A.Name, B.OrderID FROM Customers A LEFT JOIN Orders B ON A.ID = B.CustomerID WHERE B.OrderID > 100;
But it returns no rows for customers without orders. Why?
AON condition is wrong
BThe WHERE clause filters out rows where B.OrderID is NULL
CCustomers table is empty
DLEFT JOIN syntax is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Understand WHERE effect on LEFT JOIN

    WHERE filters after join; condition B.OrderID > 100 excludes rows where B.OrderID is NULL.
  2. Step 2: Result of filtering

    Customers without orders have NULL OrderID, so they are removed by WHERE clause.
  3. Final Answer:

    The WHERE clause filters out rows where B.OrderID is NULL -> Option B
  4. Quick Check:

    WHERE on right table column removes NULL rows in LEFT JOIN [OK]
Quick Trick: Use WHERE on right table columns carefully with LEFT JOIN [OK]
Common Mistakes:
MISTAKES
  • Thinking LEFT JOIN always keeps all left rows
  • Ignoring WHERE clause effect
  • Assuming syntax error causes no rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes