Skip to main content

Outer - Full Outer Join

Full Outer Join allows data that is matched from table_a and table_b, but also shows the data that table_a have and b does not have and table_b value that a does not have.

Select all from Table A and B

Syntax

In the MySQL, there is no full outer join. To do the full outer join, left join and right join is needed and later union with each other to get the same result as full outer join.

SELECT ...
FROM [table_name_A]
LEFT OUTER JOIN [table_name_B]
USING ([primary_key])

UNION

SELECT ...
FROM [table_name_A]
RIGHT OUTER JOIN [table_name_B]
USING ([primary_key])

Example

SELECT *
FROM Order
LEFT OUTER JOIN Employees
USING (P_Code)

UNION

SELECT *
FROM Order
RIGHT OUTER JOIN Employees
USING (P_Code)