JOIN: combining two tables
Rows in one table point at rows in another. JOIN is how you follow the pointer.
Open this lesson in the learning hubKey points
orders.customer_idholds thecustomers.idit belongs to - a foreign key.- A JOIN pairs rows where the ON condition matches, producing one wide row per pair.
- INNER JOIN keeps only matched pairs, so a customer with no orders disappears.
- LEFT JOIN keeps every left row, filling the right side with NULL when nothing matched.
- Aliases (
customers c) keep the query readable once two tables are in play.
INNER JOIN answers "who has orders"; LEFT JOIN also answers "who has none" - a different question.
This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the MySQL Course course, and every lesson in it is listed on the MySQL Course contents page.