Bird
0
0

Given these tables:

medium📝 query result Q13 of 15
SQL - INNER JOIN
Given these tables:

Employees
ID | Name | DeptID
1 | Alice | 10
2 | Bob | 20
3 | Carol | 30

Departments
DeptID | DeptName
10 | Sales
20 | HR
40 | IT

What is the result of this query?
SELECT Employees.Name, Departments.DeptName FROM Employees INNER JOIN Departments ON Employees.DeptID = Departments.DeptID;
A[('Alice', 'Sales'), ('Bob', 'HR')]
B[('Alice', 'Sales'), ('Bob', 'HR'), ('Carol', 'IT')]
C[('Alice', 'Sales'), ('Carol', 'IT')]
D[('Bob', 'HR'), ('Carol', 'IT')]
Step-by-Step Solution
Solution:
  1. Step 1: Match Employees.DeptID with Departments.DeptID

    Employees have DeptIDs 10, 20, 30; Departments have 10, 20, 40.
  2. Step 2: Find matching DeptIDs

    Matches are 10 and 20 only; 30 (Carol) has no matching department.
  3. Final Answer:

    [('Alice', 'Sales'), ('Bob', 'HR')] -> Option A
  4. Quick Check:

    INNER JOIN returns only matching DeptIDs [OK]
Quick Trick: Only rows with matching DeptID appear in INNER JOIN result [OK]
Common Mistakes:
MISTAKES
  • Including unmatched rows like Carol's
  • Confusing DeptID with ID
  • Assuming all departments join

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes