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 →Example
Previewing a Few Retail Orders with LIMIT
SELECT * FROM orders LIMIT 5Step by step
- Start with the basic query. Without LIMIT it returns every row in the table.
SELECT * FROM orders; - 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; - Swap 5 for 10 and you get 10 rows. Same query, just a different cap.
SELECT * FROM orders LIMIT 10;
Practice
1. Write a query to show only the first 3 rows from the orders table.
SELECT * FROM orders LIMIT 32. Write a query to show only the first 2 rows from the products table.
SELECT * FROM products LIMIT 23. Write a query to show only the first 2 rows from the store_sales table.
SELECT * FROM store_sales LIMIT 24. Write a query to show only the first 3 rows from the reviews table.
SELECT * FROM reviews LIMIT 35. Write a query to show only the first 3 rows from the employees table.
SELECT * FROM employees LIMIT 3Learn 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 →