What is the purpose (or use case) for an outer join in SQL?

user4903 picture user4903 · Jul 9, 2009 · Viewed 12.1k times · Source

Is an outer join only used for analysis by the developer? I'm having trouble finding a use case for why you would want to include data in two or more tables that is unrelated or does not "match" your select criteria.

Answer

Kevin Beck picture Kevin Beck · Jul 9, 2009

An example use case would be to produce a report that shows ALL customers and their purchases. That is, show even customers who have not purchased anything. If you do an ordinary join of customers and purchases, the report would show only those customers with at least one purchase.