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”.