LIMIT Rows in SQL

Level 241 keystrokes

LIMIT restricts the number of rows returned by a query.

SQL code

1SELECT
-- Returns the name and price columns
2 name,
3 price
4FROM
5 products
-- LIMIT 5 returns at most 5 rows, handy for previewing data
-- Without ORDER BY, which 5 rows you get is not guaranteed
6LIMIT
7 5;

Output

+--------+-------+
| name   | price |
+--------+-------+
| Apple  | 1.50  |
| Banana | 0.75  |
| Orange | 2.00  |
| Grape  | 3.00  |
| Mango  | 2.50  |
+--------+-------+
5 rows in set
Practice typing this code

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

More SQL examples at level 2

← SQL typing practice