10.3 LEFT JOIN
Level: 10 | Version: v1.1 | Author: Meptrasoft
Overview
LEFT JOIN returns all rows from the left table and the matching rows from the right table.
When no match exists, the right-side columns contain NULL.
LEFT TABLE
+
RIGHT TABLE
↓
LEFT JOIN
↓
ALL LEFT ROWS
+ MATCHING RIGHT ROWS
LEFT JOIN → Keep everything from the left table.

Practice Tables
This topic reuses the customers and orders tables from 10.2 INNER JOIN.
Some customers have no orders:
Anjali Verma
Rahul Das
Divya Nair
These customers are important for understanding LEFT JOIN.
Basic LEFT JOIN
SELECT customers.customer_name, orders.order_id
FROM customers
LEFT JOIN orders
ON customers.customer_id = orders.customer_id;
Unlike INNER JOIN, customers without orders are also returned.
Example:
| customer_name | order_id |
|---|---|
| Arun Kumar | 1 |
| Arun Kumar | 3 |
| Priya Sharma | 2 |
| ... | ... |
| Anjali Verma | NULL |
| Rahul Das | NULL |
| Divya Nair | NULL |
No matching order →
NULLon the right side.
LEFT JOIN vs INNER JOIN
INNER JOIN
→ MATCHING ROWS ONLY
LEFT JOIN
→ ALL LEFT ROWS
+ MATCHING RIGHT ROWS
For the customers and orders example:
INNER JOINexcludes customers without orders.LEFT JOINkeeps those customers.
Using Aliases
Aliases make the query easier to read:
SELECT c.customer_name, o.order_id
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id;
Here:
c → customers
o → orders
Finding Customers Without Orders
A common use of LEFT JOIN is finding rows that have no match.
SELECT c.customer_name
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id
WHERE o.order_id IS NULL;
This returns customers who have no matching order.
LEFT JOIN
↓
KEEP ALL CUSTOMERS
↓
WHERE order_id IS NULL
↓
CUSTOMERS WITHOUT ORDERS
Common Beginner Mistakes
| ✗ Mistake | ✓ Correct Understanding |
|---|---|
| LEFT JOIN keeps all rows from both tables | It keeps all rows from the left table |
| Unmatched right rows disappear completely | The left row remains and right-side columns become NULL |
| LEFT JOIN and INNER JOIN are the same | INNER JOIN removes unmatched rows |
WHERE o.order_id IS NULL finds all customers |
It finds customers with no matching order in this pattern |
| RIGHT and LEFT refer to physical table storage | They refer to the position of the tables in the query |
Placement Quick Points
LEFT JOIN
→ ALL LEFT ROWS
→ MATCHING RIGHT ROWS
NO MATCH
→ RIGHT SIDE = NULL
LEFT JOINkeeps every row from the left table.- Matching rows from the right table are added.
- If no match exists, right-side columns become
NULL. LEFT JOINis useful for finding records with and without matches.WHERE right_table.key IS NULLcan identify unmatched left rows.
Interview Questions
- What is a LEFT JOIN?
A
LEFT JOINreturns all rows from the left table and matching rows from the right table.- What happens when there is no match?
The left row is still returned, and the right-table columns contain
NULL.- What is the difference between INNER JOIN and LEFT JOIN?
INNER → Only matching rows LEFT → All left rows + matching right rows- How do you find customers without orders?
Use a
LEFT JOINand check the right-side key forNULL:WHERE o.order_id IS NULL;- Which table is the left table?
The table written immediately after
FROM.
Practice & Hands-On Exercises
Using customers and orders:
- Display all customers with their order IDs:
SELECT c.customer_name, o.order_id
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id;
- Identify customers who have no orders:
SELECT c.customer_name
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id
WHERE o.order_id IS NULL;
- Display customer names and order amounts.
- Rewrite the query using aliases.
- Explain the difference between
INNER JOINandLEFT JOIN.
💡 Tip: Test your queries using the in-browser interactive runner above.
Key Takeaway
LEFT JOIN
↓
ALL LEFT ROWS
+
MATCHING RIGHT ROWS
↓
NO MATCH → NULL
LEFT JOIN keeps every row from the left table and adds matching data from the right table; unmatched right-side values become NULL.
End of LEFT JOIN