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.