Lessons › SQL › Chapter 1: Reading data
SQL lesson
LIMIT
LIMIT keeps only the first few rows, like LIMIT 3 for three rows. It goes at the very end. On its own, LIMIT doesn't pick the biggest or newest. Sort with ORDER BY first, and LIMIT gives you the top few.
Try this lesson free →Example
Just the first few rows
SELECT *
FROM orders
LIMIT 5Step by step
- Keeps only the first 3 rows.
SELECT * FROM orders LIMIT 3 - LIMIT goes last, after everything else.
SELECT * FROM orders LIMIT 3 - Sort first, and LIMIT gives you the top 3.
SELECT * FROM orders LIMIT 3
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 full_name and role of the first 3 rows from the employees table.
SELECT full_name, role 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 →