Chapter 13. SELECT Statement: The LIMIT Clause
13.1 Introduction
Many questions that MySQL will have to process begin with such phrases as “Get the top three...” or “Get the last six...” If we want to know one highest or one lowest value, we can use the MAX
and MIN
functions, respectively. If we ask for more than one row, it becomes difficult. This is where the LIMIT
clause is useful. With such a clause, you can extend a select block from which a table expression has been built.
The LIMIT
clause is the last clause of a select block with which a subset of the rows can be selected, so the number of rows in the intermediate result can be reduced again. No condition is specified with the LIMIT
clause, as with the WHERE
and HAVING
clauses, but an ...
Get SQL for MySQL Developers: A Comprehensive Tutorial and Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.