Home > Database > Mysql Tutorial > How Does MySQL\'s LIMIT with OFFSET Control Row Retrieval?

How Does MySQL\'s LIMIT with OFFSET Control Row Retrieval?

Patricia Arquette
Release: 2024-11-30 12:25:11
Original
432 people have browsed it

How Does MySQL's LIMIT with OFFSET Control Row Retrieval?

LIMIT with OFFSET in MySQL: Rows Returned

MySQL's LIMIT and OFFSET clauses allow users to control the number of rows retrieved and the starting point for those rows. The following query:

SELECT column
FROM table
LIMIT 18 OFFSET 8
Copy after login

returns 18 rows from the specified table, starting from row number 9. OFFSET specifies the number of rows to skip before starting to retrieve results. In this case, it skips the first 8 rows. LIMIT then limits the number of rows returned from the remaining results to 18.

Hence, the query retrieves results from row 9 (OFFSET 1) to row 26 (OFFSET 18). The output will contain 18 rows starting from record number 9 and ending at record number 26.

Refer to the official MySQL documentation for more information on using LIMIT and OFFSET clauses effectively.

The above is the detailed content of How Does MySQL\'s LIMIT with OFFSET Control Row Retrieval?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template