萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> oracle教程 >> Oracle的翻頁Sql語句

Oracle的翻頁Sql語句

StringBuffer pagingSelect = new StringBuffer(100); pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
pagingSelect.append(sql);
pagingSelect.append(" ) row_ where rownum <= " + endRow + ") where rownum_ > " + startRow);

startRow 是記錄開始處
endRow 是記錄結束處

舉例來說:
從第11條到第20條

select * from (

select row_.*, rownum rownum_ from (

select person_id, chn_name, chn_firstname_py from t_pbase_info

) row_ where rownum <=20

) where rownum_ >=11

copyright © 萬盛學電腦網 all rights reserved