0
0
SQLquery~20 mins

INNER JOIN syntax in SQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
INNER JOIN Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this INNER JOIN query?

Consider two tables:

Employees:
id | name
1 | Alice
2 | Bob
3 | Carol

Departments:
emp_id | department
1 | Sales
3 | HR
4 | IT

What rows will this query return?

SELECT Employees.name, Departments.department
FROM Employees
INNER JOIN Departments ON Employees.id = Departments.emp_id;
SQL
SELECT Employees.name, Departments.department
FROM Employees
INNER JOIN Departments ON Employees.id = Departments.emp_id;
A[{"name": "Alice", "department": "Sales"}, {"name": "Bob", "department": "HR"}]
B[{"name": "Bob", "department": "Sales"}, {"name": "Carol", "department": "HR"}]
C[{"name": "Alice", "department": "Sales"}, {"name": "Carol", "department": "HR"}]
D[{"name": "Alice", "department": "Sales"}, {"name": "Carol", "department": "HR"}, {"name": "Bob", "department": "IT"}]
Attempts:
2 left
💡 Hint

INNER JOIN returns only rows with matching keys in both tables.

🧠 Conceptual
intermediate
1:30remaining
Which statement about INNER JOIN is true?

Choose the correct statement about INNER JOIN in SQL.

AINNER JOIN returns only rows where there is a match in both joined tables.
BINNER JOIN returns all rows from the left table, even if there is no match in the right table.
CINNER JOIN returns all rows from the right table, even if there is no match in the left table.
DINNER JOIN returns all rows from both tables, matching or not.
Attempts:
2 left
💡 Hint

Think about what 'inner' means in INNER JOIN.

📝 Syntax
advanced
2:00remaining
Which query has correct INNER JOIN syntax?

Identify the query with valid INNER JOIN syntax.

ASELECT * FROM A JOIN B WHERE A.id = B.id;
BSELECT * FROM A INNER JOIN B ON A.id = B.id;
CSELECT * FROM A INNER JOIN B USING (id);
DSELECT * FROM A INNER JOIN B ON A.id == B.id;
Attempts:
2 left
💡 Hint

Check the JOIN clause and ON condition syntax carefully.

optimization
advanced
2:30remaining
How to optimize INNER JOIN performance on large tables?

You have two large tables joined by a foreign key. Which method improves INNER JOIN query speed?

AUse CROSS JOIN instead of INNER JOIN for faster results.
BUse SELECT * to retrieve all columns to avoid specifying columns.
CRemove WHERE clause filters to reduce query complexity.
DAdd indexes on the columns used in the JOIN condition.
Attempts:
2 left
💡 Hint

Think about how databases find matching rows quickly.

🔧 Debug
expert
2:00remaining
What error does this INNER JOIN query raise?

Given these tables:

Table A: id, value
Table B: id, description

Query:

SELECT A.id, B.description
FROM A INNER JOIN B ON A.id = B.idd;

What error will this query produce?

AColumn 'B.idd' does not exist
BAmbiguous column name 'id'
CNo error, returns empty result
DSyntax error near 'idd'
Attempts:
2 left
💡 Hint

Check the column names used in the ON clause carefully.