Environment
MySQL 5.1 + command line tools
Problem
MySQL Paging
Solve
--Creates a test table CREATE TABLE test (ID int (one) primary key auto_increment, name varchar () 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)--Performs paging mysql> select Id,name from test limit 0, 10; +----+--------+
| ID |
name | +----+--------+
| 1 |
Test1 | | 2 |
Test2 | | 3 |
Test3 | | 4 |
test4 | | 5 |
Test5 | | 6 |
Test6 | | 7 |
Test7 | | 8 |
Test8 | | 9 |
Test9 | | 10 |
test10 | +----+--------+ rows in Set (0.00 sec)