mybatis下的分页
- MySQL
- 因为MySQL自带
limit
关键字分页
/**
起始索引start,结束索引end
int pageIndex=1;//当前页数
int countPage=3;//每页显示条目数
int start=(pageIndex-1)×countPage;//每页的起始索引
int end=countPage;//表示要显示的个数
因为索引从0开始
所以[start,end)=[0,3)
**/
@Select("select * from user_tab limit #{start},#{end}")
List<User>pageQuery(@Param("start")intstart,@Param("end")int end);
- Oracle
- oracle没有limit分页所以通过子查询完成
1.排序起别名u (select * from user_tab order by id ) u
2.查询所有及伪列 (select u.*,rownum r from (select * from user_tab