Challenge - 5 Problems
Master of INNER JOIN with multiple conditions
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
INNER JOIN with two conditions
Given two tables Employees and Departments, what is the result of this query?
SQL
SELECT e.EmployeeID, e.Name, d.DepartmentName FROM Employees e INNER JOIN Departments d ON e.DepartmentID = d.DepartmentID AND e.Location = d.Location;
Attempts:
2 left
💡 Hint
Remember that both conditions in the ON clause must be true for a row to join.
✗ Incorrect
The INNER JOIN matches rows where DepartmentID and Location are the same in both tables. Only Alice and Charlie meet both conditions.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in INNER JOIN with multiple conditions
Which option contains a syntax error in the INNER JOIN with multiple conditions?
SQL
SELECT e.EmployeeID, e.Name, d.DepartmentName FROM Employees e INNER JOIN Departments d ON e.DepartmentID = d.DepartmentID AND e.Location = d.Location;
Attempts:
2 left
💡 Hint
Check the use of AND and commas in the ON clause.
✗ Incorrect
Option D uses a comma instead of AND in the ON clause, which is invalid syntax for JOIN conditions.
❓ optimization
advanced2:00remaining
Optimizing INNER JOIN with multiple conditions
Which option is the most efficient way to write an INNER JOIN with multiple conditions for large tables?
Attempts:
2 left
💡 Hint
INNER JOIN with ON clause is generally more efficient than WHERE with comma joins.
✗ Incorrect
Option B uses INNER JOIN with multiple conditions in ON clause, which is optimized by SQL engines. Option B uses implicit join syntax which is less efficient. Option B uses OR which is less selective. Option B uses LEFT JOIN with filter which is less efficient.
🔧 Debug
advanced2:00remaining
Why does this INNER JOIN return no rows?
Given these tables, why does this query return no rows?
SELECT e.EmployeeID, d.DepartmentName
FROM Employees e
INNER JOIN Departments d
ON e.DepartmentID = d.DepartmentID AND e.Location = d.Location;
Attempts:
2 left
💡 Hint
Check if the join conditions match any rows in both tables.
✗ Incorrect
INNER JOIN returns rows only when all conditions in ON clause are true. If no rows match both DepartmentID and Location, result is empty.
🧠 Conceptual
expert2:00remaining
Understanding INNER JOIN with multiple conditions logic
Which statement best describes how INNER JOIN with multiple conditions works?
Attempts:
2 left
💡 Hint
Think about how AND works in the ON clause.
✗ Incorrect
INNER JOIN with multiple conditions uses AND logic, so only rows matching all conditions are returned.