When to use inner joins versus outer joins

What are real life examples of when to use inner versus outer joins? Would it be safer to use outer joins first since it returns all items including null and then just determine from there if the rows that return null are worth keeping? Thanks.

Say you have a customers table and an orders table, and you want to get the data on the customers and their orders, even for those customers who don’t yet have any orders. You could use an outer join, because you’ll get a row even for those customers without an order. If instead you want the data on just those customers who have placed orders, you could use an inner join, because you won’t get any rows for those customers who don’t have an order. The query that you write, inner join vs outer join etc., depends on the question you are asking of your data.

2 Likes