Bird
0
0

Given two tables:

medium📝 query result Q13 of 15
SQL - Advanced Joins
Given two tables:
Employees(emp_id, name, dept_id)
Departments(dept_id, dept_name, location)
What will be the result of this query?
SELECT emp_id, name, dept_name FROM Employees NATURAL JOIN Departments;
ASyntax error due to missing ON clause
BRows combining employees with their department names based on matching dept_id
COnly employees with no department
DAll employees repeated for each department
Step-by-Step Solution
Solution:
  1. Step 1: Identify common columns for NATURAL JOIN

    Both tables share dept_id, so NATURAL JOIN matches rows where dept_id is equal.
  2. Step 2: Understand the output columns

    The query selects emp_id, name from Employees and dept_name from Departments, showing employee info with their department name.
  3. Final Answer:

    Rows combining employees with their department names based on matching dept_id -> Option B
  4. Quick Check:

    NATURAL JOIN matches on dept_id, returns combined rows [OK]
Quick Trick: Natural join matches on common columns, returns combined rows [OK]
Common Mistakes:
MISTAKES
  • Expecting all employees repeated for each department
  • Thinking NATURAL JOIN returns unmatched rows
  • Assuming syntax error without ON clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes