The Wayback Machine - https://web.archive.org/web/20261118122130/https://www.geeksforgeeks.org/postgresql/postgresql-full-outer-join/

PostgreSQL - FULL OUTER JOIN

Last Updated : 4 Nov, 2026

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.
full-join
Full Outer Join

Syntax

SELECT table_1.column_1, table_1.column_2, table_2.column_1, ...
FROM table_1
FULL OUTER JOIN table_2
ON 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

Screenshot-2026-10-04-164859

projects table

Screenshot-2026-10-04-165057

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:

Screenshot-2026-10-04-165123

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:

Screenshot-2026-10-04-165151
Comment

Explore