1.mysql的数据库分页
mysql> select pname from
product;
+--------+
| pname
|
+--------+
| 产品1
|
| 产品2
|
| 产品三 |
+--------+
3 rows in set (0.00 sec)
这个地方是说,从product中选出所有的pname来,一共有三条记录。
MySQL中的分页非常简单,我们可以使用limit
比如:
mysql> select pname from
product limit(0,2);
+-------+
| pname |
+-------+
| 产品1 |
| 产品2 |
+-------+
2 rows in set (0.00 sec)
Limit用法如下:
第一个参数是指要开始的地方,第二个参数是指每页显示多少条数据;
注:第一页用0表示。

Mysql分页:
select
* from tableName where
条件 limit 当前页码*页面容量-1 , 页面容量
2.SQLServer中的分页
从publish 表中取出第 n 条到第 m 条的记录:
SELECT TOP m-n+1 *
FROM publish
WHERE (id NOT IN
(SELECT TOP n-1 id
FROM publish))
id 为publish 表的关键字
3.oracle中的分页语句
1)、一种是利用相反的。
PAGESIZE:每页显示的记录数
CURRENTPAGE:当前页号
数据表的名字是:components
索引主键字是:id
select * from components where id not in(select id from components
where rownum<=(PAGESIZE*(CURRENTPAGE-1))) and
rownum<=PAGESIZE order by id;
如下例:
select * from components where id not in(select id from components
where rownum<=100) and rownum<=10
order by id;
从101到记录开始选择,选择前面10条。
2)、使用minus,即中文的意思就是减去,呵呵,这语句非常的有意思,也非常好记
select * from components where
rownum<=(PAGESIZE*(CURRENTPAGE-1)) minus select *
from components where
rownum<=(PAGESIZE*(CURRENTPAGE-2));
如例:select * from components where rownum<=10 minus
select * from components where rownum<=5;.
3)、一种是利用Oracle的rownum,这个是Oracle查询自动返回的序号,一般不显示,但是可以通过select rownum
from
[表名],可以看到,是从1到当前的记录总数。
select * from (select rownum tid,components.* from components where
rownum<=100) where
tid<=10;