Home > Database > Mysql Tutorial > body text

How to implement paging in mysql

WBOY
Release: 2022-01-20 15:58:53
Original
13493 people have browsed it

Method: 1. Use limit to realize paging, the syntax is "SELECT*FROM table name limit starting record number, number of records per page"; 2. Use primary key index to realize paging, the syntax is "SELECT*FROM table name WHERE field name> (number of pages*10) LIMIT number of items".

How to implement paging in mysql

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How to implement paging in mysql

First write a query statement for a table, and then add limit after the statement to achieve the paging effect.

Click to run and you will get 10 records on the first page, as shown in the figure. This kind of paging is generally used to implement paging for tables with relatively small data,

How to implement paging in mysql

Method 2

Right-click on the table, open the right-click menu list, click on the design table, enter the design table window, click on the index, enter the index window to complete the setting of the primary key index,

Then When using SELECT * FROM test WHERE id > (1*10) LIMIT 30 to implement paging, 1 is the number of pages and 30 is the number of entries. This will be faster when used in tables with a large amount of data, as shown in Figure

How to implement paging in mysql

Recommended learning: mysql video tutorial

The above is the detailed content of How to implement paging in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!