Bird
0
0

How would you modify a self join query to also include employees who do not have a manager, showing NULL for manager name?

hard📝 Application Q9 of 15
SQL - INNER JOIN
How would you modify a self join query to also include employees who do not have a manager, showing NULL for manager name?
AUse LEFT JOIN instead of INNER JOIN in the self join query
BAdd WHERE manager_id IS NULL to filter employees without managers
CUse RIGHT JOIN instead of INNER JOIN in the self join query
DUse UNION to combine employees with and without managers
Step-by-Step Solution
Solution:
  1. Step 1: Understand join types

    INNER JOIN excludes rows without matches; LEFT JOIN includes all from left table, NULL if no match.
  2. Step 2: Apply to self join

    Using LEFT JOIN on employees to themselves shows all employees, with NULL for missing managers.
  3. Final Answer:

    Use LEFT JOIN instead of INNER JOIN in the self join query -> Option A
  4. Quick Check:

    LEFT JOIN shows unmatched rows with NULL [OK]
Quick Trick: LEFT JOIN includes rows without matching join partner [OK]
Common Mistakes:
MISTAKES
  • Using INNER JOIN only
  • Filtering with WHERE instead of join type
  • Using UNION unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes