← All posts
postMay 23, 2026
SQL INNER JOIN — combine tables on a key
#sql#join#intermediate
sql
SELECT
u.email,
o.order_id,
o.total
FROM users u
INNER JOIN orders o
ON u.id = o.user_id
WHERE o.created_at >= '2026-05-01'
ORDER BY o.total DESC;Production databases split data across many tables for normalization — users in one table, orders in another, products in a third. To answer business questions, you need to combine them.
INNER JOIN returns rows where the join condition matches in both tables. It is the most common type. The pattern is always: SELECT columns FROM table_a JOIN table_b ON table_a.key = table_b.key. Master this and 70 percent of analytical queries become straightforward.