码迷,mamicode.com
首页 > Web开发 > 详细

大三在校生的传智120天的1200小时.net(十二)关于高效分页

时间:2015-02-08 18:09:19      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

分页规律

方法1(最常用):

start:(pageIndex-1)*pageSize+1    end:pageIndex*pageSize

select * from
(select *,row_number() over(order by Id desc) as rowIndex from tb_Person where RowIndex) as tb_new
where rowIndex between (@pageIndex-1)*@pageSize+1 and @pageIndex*@pageSize

 

方法2(靠前面和后面的页面查询速度快)越过多少行  取多少行

select top(@pageSize)*

from tb_News where ID not exits in

select top (@pageIndex-1)*@pageSeze  * from tb_News ;

大三在校生的传智120天的1200小时.net(十二)关于高效分页

标签:

原文地址:http://www.cnblogs.com/tdws/p/4280232.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!