在sql2005以上的版本中可以用如下代码:
[email protected] 是页码(要查询第几页),@pageSize是页容量(即每页显示多少条数据)
select * from (select row_number() over(order by id) rn,* from Test)tb where rn >(@PageNo-1)[email protected] and rn <[email protected][email protected]
以上只是简单的分页,如果还有其他逻辑,比如排序 可以在over中加入排序的方法 test表 也可以换成子查询等其他逻辑
在oracle中,可以使用如下语句
select t2.* from (select rownum r,t1.* from test t1 where rownum<=:PageNo*:pageSize) t2 where t2.r>(:PageNo-1)*:pageSize
[email protected]:’意义都是相同的! 只需在查询时传入需要的参数即可