Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

OUTER JOIN

FULL OUTER JOIN

The FULL OUTER JOIN command retrieves all rows from both tables when there is a match in either the left or right table.

The following SQL statement selects all customers and all orders:

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
FULL OUTER JOIN Orders ON Customers.CustomerID=Orders.CustomerID
ORDER BY Customers.CustomerName;

NOTE: The FULL OUTER JOIN keyword retrieves all rows from both the left table (Customers) and the right table (Orders). It includes rows from “Customers” without matches in “Orders” and rows from “Orders” without matches in “Customers”.