Bird
0
0

Given tables Employees and Departments with columns Employees.DeptID, Departments.ID, and Departments.Location, what will this query return?

medium📝 query result Q13 of 15
SQL - INNER JOIN
Given tables Employees and Departments with columns Employees.DeptID, Departments.ID, and Departments.Location, what will this query return?
SELECT Employees.Name, Departments.Name FROM Employees INNER JOIN Departments ON Employees.DeptID = Departments.ID AND Departments.Location = 'NY';
ASyntax error due to multiple conditions in JOIN.
BAll employees with their department names regardless of location.
CDepartments located in NY with all employees listed multiple times.
DEmployees working only in departments located in NY with their department names.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the JOIN conditions

    The query joins Employees and Departments where DeptID matches ID and the department location is 'NY'.
  2. Step 2: Analyze the result rows

    Only employees whose department is in NY will appear with their department names. Others are excluded.
  3. Final Answer:

    Employees working only in departments located in NY with their department names. -> Option D
  4. Quick Check:

    INNER JOIN + multiple conditions filters rows precisely [OK]
Quick Trick: Multiple conditions filter rows strictly in INNER JOIN [OK]
Common Mistakes:
MISTAKES
  • Assuming all employees appear regardless of location
  • Thinking multiple conditions cause syntax error
  • Confusing join condition with WHERE clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes