Oracle分頁語句

2022-06-22 04:48:08 字數 685 閱讀 4552

select * from (select a.*,rownum rd from (select * from [tablename] where [condition] order by  [condition] ) a  where rownum<=[endpage*pagesize]) where rd>=[startpage*pagesize];

1.select * from [tablename] where [condition] order by  [condition] 

按條件對資料表進行篩選排序,作為分頁的基本資料

2.select a.*,rownum rd from (select * from [tablename] where [condition] order by  [condition] ) a  where rownum<=[endpage*pagesize]

使用rownum選擇小於結尾頁的資料,必須對rownum採用別名

3.select * from (select a.*,rownum rd from (select * from [tablename] where [condition] order by  [condition] ) a  where rownum<=[endpage*pagesize]) where rd>=[startpage*pagesize]

在2中得到的表中選擇大於開始頁的資料

oracle 分頁語句

1.根據rowid來分 select from t xiaoxi where rowid in select rid from select rownum rn,rid from select rowid rid,cid from t xiaoxi order by cid desc where r...

oracle分頁語句

1.根據rowid來分 select from t xiaoxi where rowid in select rid from select rownum rn,rid from select rowid rid,cid from t xiaoxi order by cid desc where r...

Oracle分頁語句

select from select a.rownum r from 這裡的sql可以改成你真正要執行的sql select from articles order by pubtime desc a 用上面的sql得回來的集合,使用rownum去比對,這樣rownum就會從這 個集合的第一筆資料開...