MySQL Limit with Offset: What Results Are Returned?
In MySQL, the LIMIT and OFFSET clauses allow you to retrieve a specific number of rows from a table, starting at a given offset. This article explores how the LIMIT and OFFSET clauses interact to determine which rows are returned from a query.
Consider the following example query:
SELECT column FROM table LIMIT 18 OFFSET 8
How Many Results Will Be Returned?
The LIMIT clause specifies that 18 rows will be returned by the query.
Where Will the Results Start?
The OFFSET clause indicates that the results will start at row #9. This is because OFFSET specifies the number of rows to skip before beginning to return results.
To better understand how this works, let's break down the query:
In summary, the query above will return 18 results, starting from record #9 and ending at record #26. For more information, refer to the official MySQL documentation on LIMIT and OFFSET.
The above is the detailed content of MySQL LIMIT and OFFSET: How Many Rows Are Returned and Where Do They Start?. For more information, please follow other related articles on the PHP Chinese website!