SQL FULL JOIN
FULL JOIN (or FULL OUTER JOIN) returns all rows from both tables.
If rows match, they are combined. If there is no match, the missing side will contain NULL values.
So it is basically:
LEFT JOIN + RIGHT JOIN combined.
Syntax
SELECT columns FROM table1 FULL JOIN table2 ON table1.column = table2.column; Returns all rows from table1 Returns all rows from table2 Non-matching columns appear as NULL
Example
SELECT Customers.name, Orders.order_id FROM Customers FULL JOIN Orders ON Customers.customer_id = Orders.customer_id;
Example:Some databases like MySQL do not support FULL JOIN directly. You must simulate it using LEFT JOIN + RIGHT JOIN with UNION.
SELECT * FROM table1 LEFT JOIN table2 ON table1.id = table2.id UNION SELECT * FROM table1 RIGHT JOIN table2 ON table1.id = table2.id;