0
点赞
收藏
分享

微信扫一扫

sql--分页

sin信仰 2022-01-27 阅读 68

方法1:top方式分页

--查询第一页

select top 5 * from student

--查询第二页

select top 5 *from student where stuid not in (select top 5 stuid from student)

--查询第三页

select top 5 *from student where stuid not in (select top 10 stuid from student)

综上所述:得出规律:

select top 页码大小 *from student where stuid not in(select top 页码大小*(当前页-1)stuid from student)

方法2:row_number分页

格式:

row_number() over(order by 主键)

例:

select         row_number() over(order by stuid) as Rowid,*from student where Rowid between ((当前页-1)*页码大小+1) and (当前页*页码大小)

举报

相关推荐

0 条评论