Last updated
SQL LIMIT
Definition: LIMIT restricts how many rows the query returns — perfect for previews and "top N" lists.
Example 1 — first 3 rows
SELECT * FROM Customers LIMIT 3;
Example 2 — the 3 most expensive products
Combine ORDER BY with LIMIT to get a top list:
SELECT ProductName, Price FROM Products ORDER BY Price DESC LIMIT 3;
A note on database differences
MySQL, PostgreSQL, and SQLite use LIMIT. Microsoft SQL Server uses SELECT TOP 3 ... instead. The idea is the same; only the keyword differs.
💡 Tip: LIMIT is great for pagination — showing results one page at a time.
Try it Yourself
Output
Ad · responsive