各种数据库分页

阅读更多
  • Oracle
select * from (select a.*,rownum rc from 表名 where rownum<=endrow) a where a.rc>=startrow;

 

  •  DB2
Select * from (select rownumber() over() as rc,a.* from (select * from 表名 order by 列名) as a) where rc between startrow and endrow

  •  SQL Server 2000
Select top pagesize * from 表名 where 列名 not  in(select top pagesize*page 列名 from  表名 order by 列名) order by 列名

  •  SQL Server 2005
Select * from (select 列名,row_搜索number() over(order by  列名1) as +R名from 表名) as t where t.列名1>=startrow and t.列名1<=endrow
 
  • MySQL
Select * from 表名 limit startrow,pagesize
 
  • PostgreSQL
Select * from 表名 limit pagesize,offset startrow
 
  • 通用
select * from ( select * from tb_student where sid not in(select sid from tb_student where rownum<=(currentPage-1)*pageSize)) where rownum <=pageSize;
 

你可能感兴趣的:(各种数据库分页)