Bird
0
0

What will this query output? SELECT Departments.name, Employees.name FROM Departments RIGHT OUTER JOIN Employees ON Departments.id = Employees.dept_id;

medium📝 query result Q5 of 15
SQL - LEFT and RIGHT JOIN
What will this query output? SELECT Departments.name, Employees.name FROM Departments RIGHT OUTER JOIN Employees ON Departments.id = Employees.dept_id;
AAll departments with their employees; NULL if no employee
BAll employees with their department names; NULL if no department
COnly employees with matching departments
DOnly departments with matching employees
Step-by-Step Solution
Solution:
  1. Step 1: Understand RIGHT OUTER JOIN

    RIGHT OUTER JOIN keeps all rows from Employees (right table) and matches Departments; unmatched Departments show NULL.
  2. Step 2: Interpret output columns

    Employees.name always present; Departments.name NULL if no matching department.
  3. Final Answer:

    All employees with their department names; NULL if no department -> Option B
  4. Quick Check:

    RIGHT OUTER JOIN keeps all right rows with NULLs for unmatched left [OK]
Quick Trick: Right outer join keeps all right table rows [OK]
Common Mistakes:
MISTAKES
  • Mixing up left and right tables
  • Expecting only matched rows
  • Assuming NULLs are replaced with defaults

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes