INNER JOIN in SQL
Level 390 keystrokes
INNER JOIN returns rows that have matching values in both tables.
SQL code
-- Take the name from users and the total from orders1SELECT2 users.name,3 orders.total-- users is the left (first) table of the join4FROM5 users-- Pair each user with each of their orders, matched on users.id = orders.user_id-- Users without orders are left out; a user with 2 orders appears twice (Alice)6INNER JOIN7 orders ON users.id = orders.user_id;Output
+-------+-------+ | name | total | +-------+-------+ | Alice | 99.50 | | Alice | 45.00 | | Bob | 75.25 | +-------+-------+ 3 rows in set
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this SQL code and how often they appear.
.× 4_× 1,× 1;× 1=× 1