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".
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
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,
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
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!