Bird
0
0

You wrote this query but it returns fewer rows than expected:

medium📝 Debug Q14 of 15
SQL - INNER JOIN
You wrote this query but it returns fewer rows than expected:
SELECT * FROM Products JOIN Categories ON Products.CategoryID = Categories.ID;

What is the most likely cause?
AThere are Products with CategoryID values not present in Categories
BThe query needs a WHERE clause to filter rows
CThe JOIN keyword is missing
DThe join condition column names are swapped
Step-by-Step Solution
Solution:
  1. Step 1: Analyze INNER JOIN behavior

    INNER JOIN returns only rows where the join condition matches in both tables.
  2. Step 2: Consider missing matches

    If some Products have CategoryID values not in Categories, those Products are excluded, reducing rows.
  3. Final Answer:

    There are Products with CategoryID values not present in Categories -> Option A
  4. Quick Check:

    Missing matches cause fewer rows in INNER JOIN [OK]
Quick Trick: INNER JOIN excludes rows without matching keys [OK]
Common Mistakes:
MISTAKES
  • Thinking swapped column names cause fewer rows
  • Assuming JOIN keyword missing causes fewer rows
  • Believing WHERE clause is needed to fix join

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes