INNER JOIN in SQL
Level 4115 keystrokes
INNER JOIN returns only rows that have a match in both tables; WHERE then filters the joined rows.
SQL code
-- Take the user's name and the order total from the two tables1SELECT2 users.name,3 orders.total4FROM5 users-- Join each user to their orders where users.id = orders.user_id-- Users without orders do not appear at all6INNER JOIN7 orders ON users.id = orders.user_id-- Keep only orders over 100; Alice appears twice because she has two of them8WHERE9 orders.total > 100;Output
+-------+--------+ | name | total | +-------+--------+ | Alice | 150.00 | | Bob | 250.00 | | Alice | 175.00 | +-------+--------+ 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.
.× 5_× 1,× 1;× 1=× 1>× 1