Part 62: INNER JOIN: Matching Rows Across Multiple Tables
The most commonly used join. An INNER JOIN returns only the records that have matching values in both tables.
1. Syntax
SELECT
orders.id AS order_id,
users.first_name,
users.last_name,
orders.total_amount
FROM orders
INNER JOIN users ON orders.user_id = users.id;
2. Table Aliases for Readability
Always use short, descriptive table aliases to keep complex joins readable:
SELECT
o.id,
u.email,
o.total_amount
FROM orders o
JOIN users u ON o.user_id = u.id;
(Note: JOIN without specifying INNER defaults to INNER JOIN).
Key Takeaways
INNER JOINdiscards any rows that fail theONcondition in either table.
In Part 63, we will explore LEFT (OUTER) JOIN: Preserving Unmatched Left Rows!

