Oracle、MySQL和SqlServe三種數據庫分頁查詢語句的差別引見。本站提示廣大學習愛好者:(Oracle、MySQL和SqlServe三種數據庫分頁查詢語句的差別引見)文章只能為提供參考,不一定能成為您想要的結果。以下是Oracle、MySQL和SqlServe三種數據庫分頁查詢語句的差別引見正文
先來界說分頁語句將要用到的幾個參數:
int currentPage ; //以後頁
int pageRecord ; //每頁顯示記載數
以之前的ADDRESSBOOK數據表為例(每頁顯示10筆記錄):
1、SqlServe下載 分頁語句
String sql = "select top "+pageRecord +" * from addressbook where id not in (select top "+(currentPage-)*pageRecord +" id from t_user)"; // (currentPage-)*pageRecord : 是指從第幾個記載開端
第二頁SQL演示:
select top 20 * from addressbook where id not in (select top 10 id from addressbook)
2、MySQL數據庫分頁語句
String sql = "select * from addressbook where limit "+(currentPage-)*pageRecord +","+pageRecord +""; //select * from 表名 【前提】limit M,N; //M為從第幾個記載開端,好比每頁顯示筆記錄,第二頁就必需從第筆記錄開端 //N每頁讀幾個數據
第二頁SQL演示:
select * from addressbook where limit 10,10
3、Oracle數據庫分頁語句
String sqls = "select * from ( select rownum rn,t.* from addressbook t where rownum <= "+currentPage*pageRecord+" ) where rownum > "+(currentPage -1)*pageRecord;
第二頁SQL演示:
select * from ( select rownum rn,t.* from addressbook where rownum<= 20 ) where rownum > 10
以上所述是小編給年夜家引見的Oracle、MySQL和SqlServe三種數據庫分頁查詢語句的差別引見,願望對年夜家有所贊助!