不同数据库SQL语句分页

mysql 分页
select * from t_order limit 5,10



postgresql 分页

select * from newscontent limit 20 offset 0

sql server 分页

select * from (select top 10 * from (select top (10*6) * from tr_data_userinfo order by available asc) as temptable1 order by available desc) as temptable2 order by available asc



Oracle 分页(rownum)

minus差分页 select * from table where rownum<=10 minus select * from table where rownum<=5

rownum伪列select * from (select rownum tid,t.* from table t where rownum<=10) where tid<=10 and tid>=5

notin相反select * from table where id not in(select id from table where rownum<=5) and rownum<=5

前题是id排序的select * from table where id>(select max(id) from table where rownum<=5) and rownum<=5

猜你喜欢

转载自binbinwudi.iteye.com/blog/1675030