Bird
0
0

Given tables Employees (primary key EmployeeID) and Departments (foreign key ManagerID referencing EmployeeID), what will this query return?

medium📝 query result Q13 of 15
SQL - INNER JOIN
Given tables Employees (primary key EmployeeID) and Departments (foreign key ManagerID referencing EmployeeID), what will this query return?
SELECT Employees.Name, Departments.DepartmentName FROM Employees JOIN Departments ON Employees.EmployeeID = Departments.ManagerID;
ASyntax error due to wrong join condition
BList of employee names who manage departments with their department names
CList of departments without any employee names
DList of all employees with all departments regardless of manager
Step-by-Step Solution
Solution:
  1. Step 1: Understand join condition

    The join matches Employees.EmployeeID to Departments.ManagerID, linking managers to their departments.
  2. Step 2: Result of the join

    The query returns names of employees who are managers and the names of the departments they manage.
  3. Final Answer:

    List of employee names who manage departments with their department names -> Option B
  4. Quick Check:

    Join on manager ID returns managers with departments [OK]
Quick Trick: Join foreign key to primary key shows related records [OK]
Common Mistakes:
MISTAKES
  • Thinking it returns all employees regardless of management
  • Assuming syntax error due to join condition
  • Expecting departments without managers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes