BBampaa

Lessons › SQL › Chapter 1: Reading data

SQL lesson

LIMIT

LIMIT caps how many rows a query returns, so you get a small, manageable sample instead of every single result.

Try this lesson free →
About 5–10 minutes · no sign-up needed

Example

Previewing a Few Retail Orders with LIMIT

SELECT * FROM orders LIMIT 5

Result:

Step by step

  1. Start with the basic query. Without LIMIT it returns every row in the table.
    SELECT * FROM orders;
  2. Add LIMIT 5 to cap the result at 5 rows. The number after LIMIT controls how many rows come back.
    SELECT * FROM orders
    LIMIT 5;
  3. Swap 5 for 10 and you get 10 rows. Same query, just a different cap.
    SELECT * FROM orders
    LIMIT 10;

Practice

Try each one in your head first, then open the answer.

1. Write a query to show only the first 3 rows from the orders table.
SELECT * FROM orders LIMIT 3
2. Write a query to show only the first 2 rows from the products table.
SELECT * FROM products LIMIT 2
3. Write a query to show only the first 2 rows from the store_sales table.
SELECT * FROM store_sales LIMIT 2
4. Write a query to show only the first 3 rows from the reviews table.
SELECT * FROM reviews LIMIT 3
5. Write a query to show only the first 3 rows from the employees table.
SELECT * FROM employees LIMIT 3

Learn it by doing. This lesson is a short hands-on level on Bampaa: see it work, then build and write it yourself, with instant feedback.

Try this lesson free →
About 5–10 minutes · no sign-up needed