Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does a LEFT JOIN do in SQL?
A LEFT JOIN returns all rows from the left table and the matching rows from the right table. If there is no match, the result will contain NULLs for columns from the right table.
Click to reveal answer
beginner
In a LEFT JOIN, what happens when there is no matching row in the right table?
The query returns the left table's row with NULL values for the right table's columns.
Click to reveal answer
intermediate
How does SQL execute a LEFT JOIN internally?
SQL scans the left table first, then for each row, it looks for matching rows in the right table. If matches exist, it combines them; if not, it fills right table columns with NULL.
Click to reveal answer
beginner
What is the difference between LEFT JOIN and INNER JOIN in terms of output?
LEFT JOIN returns all rows from the left table regardless of matches, while INNER JOIN returns only rows where there is a match in both tables.
Click to reveal answer
intermediate
Can a LEFT JOIN return duplicate rows? Why or why not?
Yes, if the right table has multiple matching rows for a single left table row, the LEFT JOIN will return multiple rows for that left row, one for each match.
Click to reveal answer
What will a LEFT JOIN return if the right table has no matching rows?
AAll rows from the left table with NULLs for right table columns
BNo rows
COnly rows with matching keys
DAll rows from the right table
✗ Incorrect
LEFT JOIN always returns all rows from the left table, filling NULLs for right table columns when no match exists.
Which table's rows are always fully included in a LEFT JOIN result?
ABoth tables equally
BRight table
CLeft table
DNeither table
✗ Incorrect
LEFT JOIN guarantees all rows from the left table appear in the result.
If a left table row matches multiple right table rows, how many rows appear in the LEFT JOIN result for that left row?
AOne
BMultiple, one per matching right row
CDepends on the database
DZero
✗ Incorrect
LEFT JOIN returns one row for each matching right table row combined with the left row.
What SQL keyword is used to perform a LEFT JOIN?
AINNER JOIN
BFULL JOIN
CRIGHT JOIN
DLEFT JOIN
✗ Incorrect
The keyword LEFT JOIN explicitly performs a left join operation.
Which of these is true about NULLs in a LEFT JOIN result?
ANULLs appear in right table columns when no match
BNULLs appear in left table columns when no match
CNULLs never appear in LEFT JOIN results
DNULLs appear in both tables always
✗ Incorrect
When no matching right table row exists, the right table columns show NULL.
Explain how a LEFT JOIN works and what its output looks like.
Think about what happens when there is no matching row on the right.
You got /4 concepts.
Describe the difference between LEFT JOIN and INNER JOIN in SQL.
Focus on which rows appear in the result.
You got /4 concepts.
Practice
(1/5)
1. What does a LEFT JOIN do in SQL?
easy
A. Returns only rows that have matching values in both tables
B. Returns all rows from the left table and matching rows from the right table, NULL if no match
C. Returns all rows from the right table and matching rows from the left table
D. Returns rows only from the left table without any matching
Solution
Step 1: Understand LEFT JOIN behavior
A LEFT JOIN returns all rows from the left table regardless of matches in the right table.
Step 2: Check what happens when no match exists
If no matching row exists in the right table, the result shows NULL for right table columns.
Final Answer:
Returns all rows from the left table and matching rows from the right table, NULL if no match -> Option B
Quick Check:
LEFT JOIN = all left rows + matched right rows [OK]
Hint: LEFT JOIN keeps all left rows, fills right with NULL if no match [OK]
Common Mistakes:
Confusing LEFT JOIN with INNER JOIN
Thinking LEFT JOIN returns only matching rows
Assuming NULLs never appear in results
2. Which of the following is the correct syntax for a LEFT JOIN in SQL?
easy
A. SELECT * FROM table1 LEFT JOIN table2 WHERE table1.id = table2.id;
B. SELECT * FROM table1 JOIN LEFT table2 ON table1.id = table2.id;
C. SELECT * FROM table1 LEFT JOIN table2 ON table1.id = table2.id;
D. SELECT * FROM table1 LEFT JOIN table2 USING id;
Solution
Step 1: Recall correct LEFT JOIN syntax
The correct syntax uses LEFT JOIN followed by ON clause to specify join condition.
Step 2: Check each option
SELECT * FROM table1 LEFT JOIN table2 ON table1.id = table2.id; uses correct syntax: LEFT JOIN with ON condition. SELECT * FROM table1 JOIN LEFT table2 ON table1.id = table2.id; has incorrect order. SELECT * FROM table1 LEFT JOIN table2 WHERE table1.id = table2.id; uses WHERE instead of ON. SELECT * FROM table1 LEFT JOIN table2 USING id; uses USING without parentheses, which is invalid syntax.
Final Answer:
SELECT * FROM table1 LEFT JOIN table2 ON table1.id = table2.id; -> Option C
Quick Check:
LEFT JOIN ... ON condition is standard syntax [OK]
Hint: Use LEFT JOIN ... ON condition for correct syntax [OK]
Common Mistakes:
Using WHERE instead of ON for join condition
Swapping JOIN and LEFT keywords
Confusing USING with ON without proper column names
3. Given these tables: Employees(id, name) Departments(id, dept_name, manager_id) What will this query return?
SELECT e.name, d.dept_name FROM Employees e LEFT JOIN Departments d ON e.id = d.manager_id;
medium
A. All employees with their department names if they are managers, NULL otherwise
B. Only employees who are managers with their department names
C. All departments with their managers' names
D. Only departments with managers matching employee ids
Solution
Step 1: Analyze LEFT JOIN condition
The query LEFT JOINs Employees (left) with Departments (right) on employee id matching department manager_id.
Step 2: Understand output rows
All employees appear. If an employee is a manager (id matches manager_id), department name shows; else department columns are NULL.
Final Answer:
All employees with their department names if they are managers, NULL otherwise -> Option A
Quick Check:
LEFT JOIN keeps all employees, adds department if manager [OK]
Hint: LEFT JOIN keeps all left rows, adds right data if matched [OK]
Common Mistakes:
Thinking only managers appear in result
Confusing which table is left or right
Expecting departments without managers to appear
4. Identify the error in this SQL query:
SELECT a.id, b.value FROM A a LEFT JOIN B b ON a.id = b.id WHERE b.value > 10;
medium
A. The ON clause is missing a join condition
B. The SELECT clause must include all columns from both tables
C. LEFT JOIN should be INNER JOIN for this query
D. The WHERE clause filters out rows where b.value is NULL, negating LEFT JOIN effect
Solution
Step 1: Understand LEFT JOIN with WHERE filter
The WHERE clause filters rows after join. Filtering on b.value > 10 excludes rows where b.value is NULL.
Step 2: Effect on LEFT JOIN
This filtering removes rows without matches in B, making LEFT JOIN behave like INNER JOIN.
Final Answer:
The WHERE clause filters out rows where b.value is NULL, negating LEFT JOIN effect -> Option D
Quick Check:
Filtering on right table in WHERE breaks LEFT JOIN [OK]
Hint: Use ON for right table filters, not WHERE, to keep LEFT JOIN effect [OK]
Common Mistakes:
Filtering right table columns in WHERE after LEFT JOIN
Confusing ON and WHERE clauses
Assuming LEFT JOIN always keeps all left rows regardless of WHERE
5. You want to list all customers and their last order date if any. Which query correctly uses LEFT JOIN to achieve this?
A. SELECT c.name, MAX(o.order_date) FROM Customers c LEFT JOIN Orders o ON c.id = o.customer_id GROUP BY c.name;
B. SELECT c.name, o.order_date FROM Customers c LEFT JOIN Orders o ON c.id = o.customer_id WHERE o.order_date = (SELECT MAX(order_date) FROM Orders);
C. SELECT c.name, o.order_date FROM Customers c INNER JOIN Orders o ON c.id = o.customer_id;
D. SELECT c.name, MAX(o.order_date) FROM Customers c INNER JOIN Orders o ON c.id = o.customer_id GROUP BY c.name;
Solution
Step 1: Understand requirement for all customers
We want all customers listed, even those without orders, so LEFT JOIN is needed.
Step 2: Aggregate last order date per customer
Using MAX(o.order_date) with GROUP BY c.name gives last order date or NULL if no orders.
Step 3: Check options
SELECT c.name, MAX(o.order_date) FROM Customers c LEFT JOIN Orders o ON c.id = o.customer_id GROUP BY c.name; uses LEFT JOIN and GROUP BY correctly. SELECT c.name, o.order_date FROM Customers c LEFT JOIN Orders o ON c.id = o.customer_id WHERE o.order_date = (SELECT MAX(order_date) FROM Orders); filters in WHERE, excluding customers without orders. Options A and C use INNER JOIN, excluding customers without orders.
Final Answer:
SELECT c.name, MAX(o.order_date) FROM Customers c LEFT JOIN Orders o ON c.id = o.customer_id GROUP BY c.name; -> Option A
Quick Check:
LEFT JOIN + GROUP BY + MAX gets last order date including customers without orders [OK]
Hint: Use LEFT JOIN with GROUP BY and MAX to include all left rows [OK]
Common Mistakes:
Using INNER JOIN excludes customers without orders
Filtering right table in WHERE removes unmatched rows