各种数据库的分页查询

1、oracle

通过子查询rownum方式处理

内层查询控制最大值,外层查询控制最小值

示例:

select * from ( select a.*,rownum rn from table where rn < endrow) a where a.rn > startrow

 

 2、mysql

通过limit直接处理

select * from table limit startrow ,endrow

 

3、通用模式

使用差集的方式,先查询出最大的行数 ,再查出最小的行数,二者取差集

示例:

select * from table where rownum < endrow and

id not in ( select id from table where rownum < startrow) 

posted on 2017-02-19 23:06  _故乡的原风景  阅读(199)  评论(0编辑  收藏  举报