Skip to content

OUTER

SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
ORDER BY Customers.CustomerName;
| CustomerName | OrderID |
| ------------- | ------- |
| Alfreds | 7788 |
| Berge | 9998 |
| Sanchez | NULL |
| Dupont | 1234 |

The example depicts a LEFT JOIN (a type of OUTER JOIN) where all records from Customers table and the matched records from Orders table are returned. If there is no match, the result is NULL from the right side (Orders table), as demonstrated by the Sanchez row. The ORDER BY clause is used to sort the result-set in alphabetical order by CustomerName.