The PostgreSQL FULL OUTER JOIN combines rows from two tables based on a common column.
- Returns all records from both tables.
- Displays NULL for unmatched rows.
- Combines matching records into a single result.

Syntax
SELECT table_1.column_1, table_1.column_2, table_2.column_1, ...FROM table_1FULL OUTER JOIN table_2ON table_1.matching_column = table_2.matching_column;
Where:
- table_1: The left table whose all rows are returned.
- table_2: The right table that provides matching rows.
- matching_column: The common column used to join the tables.
Example
Firstly, create the employees and Projects tables and insert the following records.
employees table

projects table

Example: FULL OUTER JOIN Query
The following query returns all employees and all projects, including unmatched records from both tables.
SELECT
e.employee_name,
p.project_name
FROM employees e
FULL OUTER JOIN Projects p
ON e.employee_id = p.employee_id;
Output:

Example: FULL OUTER JOIN with WHERE Clause
The following query returns only the unmatched employees and projects using the WHERE clause.
SELECT
e.employee_name,
p.project_name
FROM employees e
FULL OUTER JOIN projects p
ON e.employee_id = p.employee_id
WHERE e.employee_id IS NULL
OR p.employee_id IS NULL;
Output:


