为此,请使用LIMIT概念。让我们创建一个表-
mysql> create table demo40 −> ( −> id int not null auto_increment primary key, −> name varchar(40) −> );
借助insert命令将一些记录插入表中-
mysql> insert into demo40(name) values('Chris'); mysql> insert into demo40(name) values('David'); mysql> insert into demo40(name) values('Mike'); mysql> insert into demo40(name) values('Sam'); mysql> insert into demo40(name) values('Carol'); mysql> insert into demo40(name) values('bob');
使用select语句显示表中的记录-
mysql> select *from demo40;
这将产生以下输出-
+----+-------+ | id | name | +----+-------+ | 1 | Chris | | 2 | David | | 3 | Mike | | 4 | Sam | | 5 | Carol | | 6 | bob | +----+-------+ 6 rows in set (0.00 sec)
以下是在MySQL中选择下一行分页的查询-
mysql> select *from demo40 limit 4,2;
这将产生以下输出-
+----+-------+ | id | name | +----+-------+ | 5 | Carol | | 6 | bob | +----+-------+ 2 rows in set (0.00 sec)