🔄 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 NULL on 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:
- OUTER keyword is optional
- FULL JOIN = FULL OUTER JOIN
📄 Example Tables
customers
orders
📄 FULL JOIN Example
SELECT c.name, o.order_id
FROM customers c
FULL JOIN orders o
ON c.customer_id = o.customer_id;
Result
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;
