Bird
0
0

Given tables Orders and Customers with columns CustomerID, what will be the result of this query?

medium📝 query result Q13 of 15
SQL - INNER JOIN
Given tables Orders and Customers with columns CustomerID, what will be the result of this query?
SELECT Orders.OrderID, Customers.Name FROM Orders JOIN Customers ON Orders.CustomerID = Customers.CustomerID;

Assuming Orders has 3 rows with CustomerIDs 1, 2, 4 and Customers has 2 rows with CustomerIDs 1, 2.
A3 rows with OrderIDs 1, 2, 4 and matching customer names for IDs 1 and 2 only
B2 rows with OrderIDs 1 and 2 only, matching customer names
CAll 3 rows with customer names, including NULL for CustomerID 4
DNo rows because CustomerID 4 does not exist in Customers
Step-by-Step Solution
Solution:
  1. Step 1: Understand INNER JOIN behavior

    INNER JOIN returns only rows where the join condition matches in both tables.
  2. Step 2: Apply to given data

    Orders have CustomerIDs 1, 2, 4; Customers have 1, 2. Only CustomerIDs 1 and 2 match, so only those rows appear.
  3. Final Answer:

    2 rows with OrderIDs 1 and 2 only, matching customer names -> Option B
  4. Quick Check:

    INNER JOIN returns only matching rows [OK]
Quick Trick: INNER JOIN shows only matching rows from both tables [OK]
Common Mistakes:
MISTAKES
  • Expecting unmatched rows to appear with NULLs
  • Confusing INNER JOIN with LEFT JOIN
  • Assuming all rows from first table appear

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes