MSSQL分页方法两种

第一种:SQL分页的方法
第页 :3条   显示第4页   
-- 越过多少条(4-1)*3   取多少条 3  

select top 3 * from UserInfo where id not in ( select top ((4-1)*3) id from UserInfo order by UserId )
order by id 第二种:分页sql 每页3条, 第5页 select * from ( select *,ROW_NUMBER() over(order by id) as num from UserInfo ) as T where T.num between ((5-1)*3+1) and (5*3)

  

posted @ 2020-12-04 21:21  Nanyingming  阅读(821)  评论(0)    收藏  举报