Bird
0
0

Consider the table employees(id, name, manager_id). What will the following query return?

medium📝 query result Q4 of 15
SQL - INNER JOIN
Consider the table employees(id, name, manager_id). What will the following query return?

SELECT emp.name AS Employee, mgr.name AS Manager FROM employees emp INNER JOIN employees mgr ON emp.manager_id = mgr.id;
AOnly managers who have no employees
BAll employees including those without managers
CPairs of employees and their respective managers
DEmployees who do not have a manager
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the join condition

    The query joins the table to itself where emp.manager_id = mgr.id, linking employees to their managers.
  2. Step 2: Understand INNER JOIN effect

    INNER JOIN returns only rows where the join condition matches, so employees without managers are excluded.
  3. Final Answer:

    Pairs of employees and their respective managers -> Option C
  4. Quick Check:

    INNER JOIN excludes employees without managers [OK]
Quick Trick: INNER JOIN excludes unmatched rows [OK]
Common Mistakes:
MISTAKES
  • Assuming employees without managers are included
  • Confusing employee and manager roles
  • Ignoring join condition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes