Description

The SQL keyword FULL OUTER JOIN is used to join two tables, which returns the rows from both the joined tables.

  • It returns all the rows from the left table.
  • It returns all the rows from the right table.
  • It also returns all the rows from the left table, that don't have a match on the right table.
  • It also returns all the rows from the left table, that don't have a match on the right table.

FULL OUTER JOIN

The below SQL fetches data from specific columns of the joined tables.

SELECT customers.customer_name, orders.order_id
FROM customers
FULL OUTER JOIN orders ON customers.customer_id = orders.customer_id
ORDER BY customers.customer_name;

FULL OUTER JOIN All Columns

The below SQL statement fetches data from all columns of the joined tables.

SELECT *
FROM customers
FULL OUTER JOIN orders ON customers.customer_id = orders.customer_id
ORDER BY customers.customer_name;

Related Links