SQL: JOIN
Learn JOIN in SQL with practical examples.
SQL — JOIN
Overview
JOIN combines rows from two tables using a related key.
What you'll learn
- INNER JOIN
- LEFT JOIN
- ON condition
- table aliases
Syntax
SELECT ... FROM a JOIN b ON a.id=b.a_id;
Example
SELECT u.name, o.total
FROM users u
JOIN orders o ON o.user_id = u.id
ORDER BY o.total DESC;
Notes
- Index join keys for speed.
- LEFT JOIN keeps rows from the left table.
Try: Open the Playground: /en/playground/sql