Inner Join vs Left Join
An inner join keeps only rows that match in both tables. A left join keeps every row from the first table, and fills the gaps with NULL.
Inner Join
A join that keeps only the rows with a match in both tables.
An inner join returns only the rows that have a match in both tables. A customer with no orders does not appear, and neither does an order with no customer. It is the default kind of join, so a plain JOIN means INNER JOIN. Use it when you only care about things that are linked. It is the most common join by far.
Left Join
A join that keeps each row from the first table, with a match or not.
A left join returns every row from the first table, plus any matches from the second. Where there is no match, the second table's columns come back as NULL. So a customer with no orders still appears, with an empty total. Use it when you want to see what is missing as well as what is there. It is also called a left outer join.
In one line
- Inner Join
- A join that keeps only the rows with a match in both tables.
- Left Join
- A join that keeps each row from the first table, with a match or not.