12. Outer Joins

Keywords Introduced


We now advance from inner joins to outer joins. The main restriction of inner joins is that they require a match in all tables being joined to show any results. If you’re joining a Customers table to an Orders table, no data is shown for the customer if that customer hasn’t yet placed an order. This may seem like a relatively unimportant problem, but it often becomes significant with different types of data.

To use a different example, let’s say we have an Orders table and a Refunds table. The Refunds table is related to the Orders table by OrderID. In other words, all refunds are tied to a specific order. The refund can’t exist unless the order exists. ...

Get The Language of SQL, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.