Challenge - 5 Problems
INNER JOIN Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
INNER JOIN with simple ON condition
Given two tables Employees and Departments, what is the result of the following query?
SQL
SELECT Employees.Name, Departments.DepartmentName FROM Employees INNER JOIN Departments ON Employees.DepartmentID = Departments.ID;
Attempts:
2 left
💡 Hint
Think about matching DepartmentID in Employees with ID in Departments.
✗ Incorrect
The INNER JOIN returns rows where Employees.DepartmentID matches Departments.ID. Alice is in HR and Bob is in IT, so only those pairs appear.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in INNER JOIN
Which option contains a syntax error in the INNER JOIN statement?
SQL
SELECT * FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID;
Attempts:
2 left
💡 Hint
Check for missing keywords or clauses in the JOIN syntax.
✗ Incorrect
Option A is missing the ON keyword, which is required to specify the join condition.
❓ optimization
advanced2:00remaining
Optimizing INNER JOIN with multiple conditions
Which query is the most efficient way to join Sales and Products tables on both ProductID and Region?
Attempts:
2 left
💡 Hint
Consider how join conditions affect query execution and filtering.
✗ Incorrect
Option B uses INNER JOIN with both conditions in the ON clause, which is efficient and clear. Option B applies one condition in WHERE, which can cause less efficient filtering. Option B uses implicit join syntax which is less readable and can be less optimized. Option B is invalid because USING requires columns with the same name in both tables, and Region may not be named identically.
🧠 Conceptual
advanced2:00remaining
Understanding INNER JOIN behavior with NULL values
What happens when you INNER JOIN two tables on a column that contains NULL values in one table?
Attempts:
2 left
💡 Hint
Think about how NULL compares in SQL join conditions.
✗ Incorrect
INNER JOIN matches rows where join columns are equal. NULL is not equal to anything, so rows with NULL in join columns do not match and are excluded.
🔧 Debug
expert2:00remaining
Debugging unexpected INNER JOIN results
You run this query but get fewer rows than expected:
SELECT Orders.OrderID, Customers.Name FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.ID WHERE Customers.Country = 'USA';
What is the most likely reason?
Attempts:
2 left
💡 Hint
Consider how INNER JOIN and WHERE filtering interact.
✗ Incorrect
If some Orders have CustomerID values not present in Customers, those Orders are excluded by INNER JOIN, reducing rows. The WHERE clause filters after the join, but the main cause is missing matching CustomerID.