LIMIT Clause in SQL
Level 246 keystrokes
LIMIT restricts the number of rows returned.
SQL code
-- ORDER BY price sorts products from cheapest to most expensive-- LIMIT 5 keeps only the first 5 rows: the 5 cheapest products1SELECT * FROM products ORDER BY price LIMIT 5;Output
+----+--------+-------+ | id | name | price | +----+--------+-------+ | 3 | Apple | 1.00 | | 1 | Banana | 1.50 | | 5 | Orange | 2.00 | | 2 | Mango | 3.00 | | 4 | Grape | 4.00 | +----+--------+-------+ 5 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.
;× 1*× 1