目前常见的三种SQL分页方式:

--top not in方式
select top 条数 *  from tablename
where Id not in (select top 条数*页数  Id from tablename)
 
 
 
--ROW_NUMBER() OVER()方式 
 select * from ( 
    select *, ROW_NUMBER() OVER(Order by Id ) AS RowNumber from tablename
  ) as b
  where RowNumber BETWEEN 当前页数-1*条数 and 页数*条数   
 
 
 
--offset fetch next方式
--SQL2012以上的版本才支持
select * from tablename
 order by Id offset 页数 row fetch next 条数 row only

  

猜你喜欢

转载自www.cnblogs.com/yachao1120/p/9385519.html