Paging MySQL pages for three common databases (Oracle, MySQL, and SQLServer)

Source: Internet
Author: User
Tags mysql insert
MySQL paging solution-create test table createtabletest (idint (11) primarykeyauto_increment, namevarchar (20) notnull); -- insert data mysqlinsertintotest (name) values (test1 ); queryOK, 1 rowaffected (0.16sec) mysqli

Environment MySQL 5.1 command line tool problem MySQL paging solution -- create test table create table test (id int (11) primary key auto_increment, name varchar (20) not null ); -- insert data mysql insert into test (name) values ('test1'); Query OK, 1 row affected (0.16 sec) mysql I

Environment

MySQL 5.1 + command line tool

Problem

MySQL Paging

Solution

-- Create test table create table test (id int (11) primary key auto_increment, name varchar (20) not null); -- insert data mysql> insert into test (name) values ('test1'); Query OK, 1 row affected (0.16 sec) mysql> insert into test (name) values ('test2'); Query OK, 1 row affected (0.01 sec) mysql> insert into test (name) values ('test3'); Query OK, 1 row affected (0.00 sec) mysql> insert into test (name) values ('test4'); Query OK, 1 row affected (0.00 sec) mysql> insert into test (name) values ('test5'); Query OK, 1 row affected (0.03 sec) mysql> insert into test (name) values ('test6'); Query OK, 1 row affected (0.01 sec) mysql> insert into test (name) values ('test7'); Query OK, 1 row affected (0.06 sec) mysql> insert into test (name) values ('test8'); Query OK, 1 row affected (0.00 sec) mysql> insert into test (name) values ('test9'); Query OK, 1 row affected (0.01 sec) mysql> insert into test (name) values ('test10'); Query OK, 1 row affected (0.01 sec) -- execute paging mysql> select id, name from test limit; + ---- + -------- + | id | name | + ---- + -------- + | 1 | test1 | 2 | test2 | 3 | test3 | 4 | test4 | 5 | test5 | | 6 | test6 | 7 | test7 | 8 | test8 | 9 | test9 | 10 | test10 | + ---- + -------- + 10 rows in set (0.00 sec)


Running Effect

Tips

Fast data insertion:

Insert into test (name) select name from test;

For details, refer to this article: How to quickly copy data tables in MySQL

Http://blog.csdn.net/btbdylq/article/details/6827981

Summary syntax

Select id, name from test limit parameter 1, parameter 2;

Parameter 1, starting from the nth

Parameter 2: How many data records are returned

Implement paging algorithm in Java Web

Select * from tableName limit (pageNow-1) * pagesize, pagesize

PageNow: Current page

PageSize: number of records displayed per page

References

Http://zhidao.baidu.com/question/248872252.html

Http://zhidao.baidu.com/question/159608774.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.