Bird
0
0

Given tables:

medium📝 query result Q4 of 15
SQL - Table Relationships
Given tables:
Customers(id, name)
Orders(id, customer_id, amount)
What will this query return?
SELECT Customers.name, Orders.amount FROM Customers JOIN Orders ON Customers.id = Orders.customer_id;
AList of orders without customer names
BList of customer names with their order amounts
CList of all customers without orders
DError because JOIN is missing a condition
Step-by-Step Solution
Solution:
  1. Step 1: Understand JOIN with ON condition

    The JOIN matches rows where Customers.id equals Orders.customer_id.
  2. Step 2: Analyze SELECT output

    The query selects customer names and their order amounts for matching rows.
  3. Final Answer:

    List of customer names with their order amounts -> Option B
  4. Quick Check:

    JOIN with ON returns matching rows [OK]
Quick Trick: JOIN with ON returns matched rows from both tables [OK]
Common Mistakes:
MISTAKES
  • Thinking JOIN returns unmatched rows
  • Missing ON condition causes error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes