使用oracle的row_num關鍵字
select * from (
select rownum r_num,a.* from pf_message a
) where r_num <=2;
總記錄數 total_num = count(*);
總頁數 = 總記錄數/每頁顯示條數
total_pages =( total_num+per_page_num - 1) / per_page_num;
傳過來的引數: 當前頁數 current_page,每頁顯示條數 per_page_num
查詢某一頁sql條件:
當前頁面查詢起始條件(當前頁面第一條記錄):row_num > (current_page - 1)*per_page_num;
當前頁面查詢結束條件(當前頁面最後一條記錄):row_num <= current_page*per_page_num;
所以select * from (
select rownum r_num,a.* from pf_message a
) where r_num >(current_page - 1)*per_page_num and r_num <= current_page*per_page_num;
ORACLE分頁查詢
單錶分頁 start num 起始行號 end num 截止行號 select t.from select s.rownum rn from table s where rownum end num t where rn start num 多表分頁 select from select temp....
Oracle分頁查詢
oracle的分頁查詢語句基本上可以按照本文給出的格式來進行套用。分頁查詢格式 select from select a.rownum rn from select from table name a where rownum 40 where rn 21 其中最內層的查詢select from t...
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...