MySQL SQLLesson 16Free preview
MySQL LIMIT
This lesson is part of MySQL · All levels
Summary
The LIMIT clause is used to limit the number of rows returned by a SELECT query. The basic form LIMIT n takes n of the first row in the specified order, and can be combined OFFSET for pagination such as the second page. For queries without ORDER BY, the row taken is not guaranteed to be in order, so always determine the order when the result should be consistent.
Key points
- Limit n limits the result to n lines
- LIMIT offset, count or LIMIT count OFFSET offset is used for pagination
- LIMIT is often combined with ORDER BY to take for example the top 5 or top 10
- The order of the lines without ORDER BY is not guaranteed, so the LIMIT results can vary
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.