🔄 FULL JOIN in SQL
Last Updated: January 2026
The FULL JOIN returns all rows from both tables.
- Matching rows → combined
- Non-matching rows → filled with
NULLon the other side - In short: LEFT JOIN + RIGHT JOIN together.
Hinglish Tip 🗣: Dono tables ka poora data chahiye, match ho ya na ho →
FULL JOIN.
🧾 Basic Syntax
SELECT columns
FROM table1
FULL OUTER JOIN table2
ON table1.common_column = table2.common_column;
Note:
OUTERkeyword is optionalFULL JOIN=FULL OUTER JOIN
📄 Example Tables
customers
| customer_id | name |
|---|---|
| 1 | Rahul |
| 2 | Anjali |
| 3 | Aman |
orders
| order_id | customer_id |
|---|---|
| 101 | 1 |
| 102 | 3 |
| 103 | 4 |
📄 FULL JOIN Example
SELECT c.name, o.order_id
FROM customers c
FULL JOIN orders o
ON c.customer_id = o.customer_id;
✅ Result
| name | order_id |
|---|---|
| Rahul | 101 |
| Anjali | NULL |
| Aman | 102 |
| NULL | 103 |
Explanation:
- Rahul & Aman → matched rows
- Anjali → customer without order
- Order 103 → order without customer
⚠️ Database Support Note
- ✅ PostgreSQL → supported
- ✅ SQL Server → supported
- ❌ MySQL → NOT supported directly
MySQL Alternative UNION
Must return the same number of columns as the first query and the same number of rows as the second query because SQL does not know how to merge the results.
SELECT c.name, o.order_id
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id
UNION
SELECT c.name, o.order_id
FROM customers c
RIGHT JOIN orders o
ON c.customer_id = o.customer_id;