Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using the limit method in PHP mysql

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 247

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report