Lecture 10: LIMIT paging query example of DQL data query statement

LIMIT paging query example of DQL data query statement

1. Paging query concept and syntax format

There are pagination functions in many programs, such as the comment area, the items searched by Baidu, the products of the e-commerce platform, how many items are displayed on each page, and then the data is displayed on different pages according to the paging query.

The syntax format of paging query:SELECT 字段列表 FROM 表名 LIMIT 起始索引,每页查询的记录数

When using LIMIT paging query, if the starting index is not specified, the default is only the first page of the query, and the actual index is not specified, which is equivalent to limiting the number of output items. When querying data in a large table, LIMIT is generally specified to limit the output. number of bars.

The "start index" has a calculation formula, the default first page is 0, and each remaining page has its own calculation formula.

The formula for calculating the starting index:

starting index = (page number to query - 1) * number of entries displayed per page

For example, the page number we want to query is 3, and the number of items displayed on each page is 10.

<

Guess you like

Origin blog.csdn.net/weixin_44953658/article/details/126617282