想用sql做简单的分页查询,但是用rownum的时候,会出现问题。
select * from (
select t.*,rownum from (
select * from tablename where condition order by columnname) t )
where rownum>(pagecount-1)*5 and rownum<=(pagecount)*5(表名,condition筛选条件,columnname排序的列名,pagecount页数)
然后看了下帖的解释才明了。
http://blog.csdn.net/lg312200538/article/details/4587455
主要是因为rownum是伪列,需要从1开始,所以做了修改
select * from (
select t.* ,rownum as rn from (
select * from tablename where condition order by columnname) t )
where rn between (pagecount-1)*5 and (pagecount*5)
浙公网安备 33010602011771号