sqlserver中queryRunner的page分页代替MySQL中的limit的3种方法

select * from book
order by id  
offset begin rows
fetch next  pageSize rows only ;

select top pageSize * from book  where id not in(select top begin id from book)

select * from ( 
    select *, ROW_NUMBER() OVER(Order by id ) AS rowid from book
) as userTmp
where rowid > begin and rowid <= (begin+pageSize)

begin是当前页的第一条记录的索引

pageSize是当前页有几条记录
 

你可能感兴趣的:(sqlserver中queryRunner的page分页代替MySQL中的limit的3种方法)