说明:
PAGESIZE:每页显示的记录数
CURRENTPAGE:当前页号
数据表的名字是:components
索引主键:id
1、SQL Server、Access数据库
select top PAGESIZE * from components where id not in
(select top (PAGESIZE*(CURRENTPAGE-1))
id from components order by id)order by id
2、Oracle数据库
因为Oracle数据库没有Top关键字,所以这里就不能够像微软的数据据那样操作
(1)、一种是利用相反的
select * from components where id not
in(select id from components where
rownum<=(PAGESIZE*(CURRENTPAGE-1)))
and rownum<=PAGESIZE order by id
(2)、使用minus,即中文的意思就是减去
select * from components where rownum
<=(PAGESIZE*(CURRENTPAGE-1)) minus
select * from components where rownum
<=(PAGESIZE*(CURRENTPAGE-2))
(3)、一种是利用Oracle的rownum,这个是Oracle查询自动返回的序号,一般不显示,但是可以通过select rownum from [表名]看到,注意,它是从1到当前的记录总数
select * from (select rownum tid,components.
* from components where rownum<=100) where tid<=10
(???怎么觉得不对呢)