各个数据库的分页算法

各个数据库的分页算法

1.SQL SERVER  是用先逆序再正序的方法

select top 3 * from (select top 9 * from mvc_book order by bid) as s order by s.bid desc [第6,5,4条]

select * from (select top 3 * from (select top 6 * from mvc_book order by bid) as s order by s.bid desc) as s1 order by s1.bid  [第4,5,6条]

select top 6 * from mvc_book where (bid not in (select top 2 bid from mvc_book))[第3,4,5,6,7,8条]
 

2.ORACLE 用Minus和Rownum来实现 (Minus 减去  Union 联合 Intersect 返回相同的记录集)

select * from t_service_vnet_send where rownum <= 15 MINUS select * from t_service_vnet_send where rownum <= 10;

select * from (select rownum no,id,age,name from loaddata where rownum <= 3 ) where no >= 2;

3.DB2
select * from (select ROW_NUMBER() over() as a, org.* from org) as temp where a>=n1 and a<=n2

4.MYSQL
select * from tablename limit m,n;

你可能感兴趣的:(各个数据库的分页算法)