Using the limit method in PHP mysql
Below to bring you about the use of limit method in PHP mysql content, I believe you must have read similar articles. What's the difference between what we bring to everyone? Let's take a look at the text. I'm sure you'll get something after reading the limit method in PHP mysql.
Offset: used to specify the offset of the first row to return.
Count: used to specify the maximum number of rows to return.
The Limit clause accepts one or two parameters, the first parameter is the offset, the second parameter represents the count, and when only one parameter is specified, it represents the number of rows returned from the result set.
LIMIT syntax:
SELECT column1, column2,... FROM table_nameLIMIT offset, count
As shown in the table below, "Data" contains three columns "Firstname", "Lastname" and "Age".
To retrieve the first three rows from the Data table, we will use the following query:
SELECT * FROM Data LIMIT 3
To retrieve rows 2-3 (including) from the "Data" table, we will use the following query:
SELECT * FROM Data LIMIT 1,2
The following is an example of the code that PHP mysql implements the query:
Example 1:Limit condition