MySQL DatabaseLesson 70Free preview
MySQL Limit Data
This lesson is part of PHP · All levels
Summary
The LIMIT clause limits the number of rows returned by a query, for example to display top data or build a page (pagination). MySQL also supports OFFSET to pass through a number of lines first. This combination of LIMIT and OFFSET is what makes the page-to-page feature of the app.
Key points
- Limit n takes n of the first line of the query result.
- Limit the number of initial OFFSETs past the beginning of the line and then take a certain amount.
- Page two page design uses a LIMIT 10 OFFSET 10 when each page contains 10 rows.
- LIMIT also saves memory because only the necessary data is loaded.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.