Bird
0
0

Identify the issue in this SQL join:

medium📝 Debug Q7 of 15
SQL - INNER JOIN
Identify the issue in this SQL join:
SELECT E.EmployeeName, D.Name FROM Employees E JOIN Departments D ON E.DeptID = D.DepartmentID;

Given DeptID is a foreign key in Employees and DepartmentID is the primary key in Departments.
AThere is no issue; the join is correct
BThe join condition uses mismatched columns
CThe alias names are incorrect
DThe join type should be LEFT JOIN instead of JOIN
Step-by-Step Solution
Solution:
  1. Step 1: Check keys

    Employees.DeptID (FK) matches Departments.DepartmentID (PK).
  2. Step 2: Verify join syntax

    JOIN uses correct columns and aliases.
  3. Final Answer:

    There is no issue; the join is correct -> Option A
  4. Quick Check:

    Foreign key matches primary key, join syntax valid [OK]
Quick Trick: Foreign key must match primary key in JOIN [OK]
Common Mistakes:
MISTAKES
  • Assuming alias names cause errors
  • Confusing join types without context
  • Mixing up column names in ON clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes