Python MySQLLesson 122Free preview
MySQL Limit
This lesson is part of Python · All levels
Summary
This lesson explains the LIMIT clause to limit the number of lines returned by the SELECT query. You'll learn how to use LIMIT with ORDER BY to take top data, as well as the LIMIT format with offset. This combination is very useful for pagination and concise reporting.
Key points
- The limit n limits the maximum query result of n rows.
- Formal limit offset, count past the first line offset and then take the line count.
- Without ORDER BY, the returned line is not guaranteed to be in order, so always sort it first when you need a certain result.
- LIMIT only affects the display of query results, not deleting any data.
- The combination of ORDER BY DESC and LIMIT 1 is used to take the maximum value.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.