Development when it came to some database development is not very common keywords, online search a bit, in fact, used a variety of databases, pagination problem has been a nagging question. No matter what type of site development, as long as it contains a search function, involves nothing more than a problem paging.
For example, Oracle Pagination:
select * from (select a.*,rownum rc from 表名 where rownum<=endrow) a where a.rc>=startrow
select a1.* from (select student.*,rownum rn from student) a1 where rn between startpage and endpage;(使用较多)
DB2 Pagination:
Select * from (select rownumber() over() as rc,a.* from (select * from 表名 order by 列名) as a) where rc between startrow and endrow
In MySQL database paging :( feeling is all the most simple and uniform wording of the)
And for a variety of SqlServer Pagination:
It is commonly used in the row_number () function, but only supports SqlServer2005 and above
select top pagenum * from (select row_number()over(order by id)rownumber,* from a)a1 where rownumber>startpage
select * from (select row_number()over(order by id)rownumber,* from a) a1 where rownumber>startpage and rownumber<endpage+1
select * from (select row_number()over(order by id)rownumber,* from a) a1 where rownumber between startpage+1 and endpage
Also this:
select top pagenum * from a where not exists (select 1 from (select top 30 id from a order by id)a1 where a1.id=a.id) order by id
But I want to say is a paging method is a lot of people do not concern:
select * from 表 order by id OFFSET PageIndex*pagenum ROWS FETCH next pagenumrows only
This method is not very simple, but this is only available in SQL Server 2012 and above, both from the number of logical reads or response time , the actual number of rows in the implementation of key parameters such as look, OFFSET SQL Server 2012 provides / FETCH NEXT pagination than Row_Number () mode have been greatly improved.
Note: Use this method must use order by, otherwise there will be a syntax error.