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

FULL OUTER JOIN

FULL OUTER JOIN

The FULL OUTER JOIN command retrieves all rows where 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;

Reminder: The FULL OUTER JOIN keyword fetches all rows from both the left table (Customers) and the right table (Orders). If there are rows in “Customers” without matches in “Orders”, or rows in “Orders” without matches in “Customers”, those rows are also included.