Codele / How software is built
Joining tables
Customers and their orders live in two tables, linked by an id. A join matches each order to its customer. Watch the match row by row, then pick a customer.
- A foreign key is a column that holds the id of a row in another table.
- A join lines up rows from two tables where ON says they match.
- Write table.column (customers.name) so it is clear which table a column comes from.
- An inner join keeps only rows that match. A customer with no orders does not appear.
- Splitting data into tables avoids typing the same customer details again and again.
Loading the playable lesson…