LIMIT Clause
Question
What does LIMIT do?
Hint
LIMIT is useful for pagination and top-N queries.
Explanation
LIMIT restricts the maximum number of rows returned. SELECT * FROM users LIMIT 10 returns at most 10 rows. With OFFSET: LIMIT 10 OFFSET 20 skips 20 rows and returns the next 10 (pagination). Syntax varies: MySQL uses LIMIT offset, count; PostgreSQL uses LIMIT count OFFSET offset; SQL Server uses TOP; Oracle uses ROWNUM/FETCH. LIMIT is applied after ORDER BY, so it returns the top N rows after sorting. LIMIT is essential for pagination, preview queries, and preventing large result sets.
Related Resources
Related Lessons
- SELECT
Learn SELECT.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.