Bird
0
0

Consider tables:

medium📝 query result Q5 of 15
SQL - Advanced Joins
Consider tables:
Products(prod_id, name, category)
Inventory(prod_id, quantity)
What does this query return?
SELECT * FROM Products NATURAL JOIN Inventory;
AAll products with quantities, including unmatched products
BAll products with their quantities where prod_id matches, no duplicate prod_id column
COnly products without inventory
DSyntax error due to missing ON clause
Step-by-Step Solution
Solution:
  1. Step 1: Identify common columns

    Both tables share prod_id, so NATURAL JOIN uses it to join.
  2. Step 2: Understand join result

    Returns rows where prod_id matches in both tables, with one prod_id column in output.
  3. Final Answer:

    All products with their quantities where prod_id matches, no duplicate prod_id column -> Option B
  4. Quick Check:

    NATURAL JOIN returns matching rows on common columns [OK]
Quick Trick: NATURAL JOIN returns matching rows on shared columns [OK]
Common Mistakes:
MISTAKES
  • Expecting unmatched rows to appear
  • Thinking NATURAL JOIN needs ON clause
  • Confusing NATURAL JOIN with LEFT JOIN

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes