INNER JOIN vs LEFT JOIN
"What is the difference between INNER JOIN and LEFT JOIN?" is probably the most common SQL interview question. In this lesson you finally connect the shop's two tables: you see how customer_id on an order points at a customer, what each kind of JOIN returns, why Omer disappears in one and shows up w
INNER JOIN keeps only pairs that found a match. LEFT JOIN keeps every row from the left table and fills in NULL where there is no match.
- Foreign key
- A column whose value is a primary key in another table, like orders.customer_id pointing at customers.id.
- INNER JOIN
- A join that returns only pairs of rows from both tables that satisfy the ON condition.
- LEFT JOIN
- A join that returns every row from the left table, with NULL in the right table's columns when there is no match.
- ON condition
- The condition that decides which rows from the two tables belong together.