SQL 分页

来源:互联网 发布:海岛大亨5mac中文版 编辑:程序博客网 时间:2024/06/07 05:26
一.几种典型的分页SQL//每页10条数据,获取第10页数据1.use except/not in /topselect top 10 * from tablewhere id not in (select top 90 id from table order by id)order by id select top 50 * from tableexcept (select top 40 * from table)2.use not existsselect top 10 * from tablewhere not exists(select 1 from (select top 90 id from table order by id)a where a.id=table.id)order by id3.user max/topselect top 10 * from tablewhere id>(select max(id) from(select top 90 id from table order by id)a)order by id4.use row_number()select top 10 * from(select row_number() over(order by id)rownumbers,* from pagetest)awhere rownumber>90

原创粉丝点击