Bird
0
0

Consider these tables:

medium📝 query result Q5 of 15
SQL - INNER JOIN
Consider these tables:

Products
ProductID | Name
1 | Pen
2 | Pencil

Sales
ProductID | Quantity
1 | 10
3 | 5

What will this query return?
SELECT Products.Name, Sales.Quantity FROM Products INNER JOIN Sales ON Products.ProductID = Sales.ProductID;
APen 10
BPen 10<br>Pencil NULL
CPen 10<br>Pencil 5
DPen 10<br>NULL 5
Step-by-Step Solution
Solution:
  1. Step 1: Match rows on ProductID

    Only ProductID 1 matches in both tables (Pen and 10).
  2. Step 2: Exclude unmatched rows

    ProductID 2 (Pencil) and ProductID 3 in Sales have no match, so excluded.
  3. Final Answer:

    Pen 10 -> Option A
  4. Quick Check:

    INNER JOIN returns only matching rows [OK]
Quick Trick: INNER JOIN excludes rows without matching keys [OK]
Common Mistakes:
MISTAKES
  • Expecting unmatched rows with NULL values
  • Confusing INNER JOIN with OUTER JOIN
  • Assuming all rows appear

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes