Bird
0
0

What will be the output of this query?

medium📝 query result Q5 of 15
SQL - INNER JOIN
What will be the output of this query?
SELECT e.name, d.department FROM employees e INNER JOIN departments d ON e.dept_id = d.id WHERE d.location = 'NY';

Assuming departments has locations and employees have matching dept_id.
ADepartments in NY without employees
BAll employees regardless of location
CEmployees working only in NY departments
DEmployees without departments
Step-by-Step Solution
Solution:
  1. Step 1: Analyze INNER JOIN with WHERE filter

    The INNER JOIN matches employees to departments by dept_id, then filters departments located in NY.
  2. Step 2: Result interpretation

    Only employees in departments located in NY will appear in the result.
  3. Final Answer:

    Employees working only in NY departments -> Option C
  4. Quick Check:

    INNER JOIN + WHERE filters rows correctly [OK]
Quick Trick: WHERE filters after join, narrowing results [OK]
Common Mistakes:
MISTAKES
  • Assuming WHERE filters before join
  • Thinking unmatched employees appear
  • Confusing department filtering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes