首頁 > 資料庫 > mysql教程 > oracle VS mysql 的分页查询

oracle VS mysql 的分页查询

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
發布: 2016-06-07 15:01:57
原創
1197 人瀏覽過

首先是Oracle: String sql = select * from ( select t.*,rownum as num from (select * from user1 where 1=1 ; SetEntryString, Object set = m.entrySet(); Iterator io = set.iterator(); while (io.hasNext()) { Map.EntryString, Object me = (Map.En

首先是Oracle:

String sql = " select * from ( select t.*,rownum as num from (select * from user1  where 1=1 ";

Set> set = m.entrySet();
Iterator io = set.iterator();
while (io.hasNext()) {
Map.Entry me = (Map.Entry) io.next();
if("username".equals(me.getKey()) && !"".equals(me.getValue())){
sql += " and " + me.getKey() + " like '%"+ me.getValue()  +"%'" ;
}
if("startTime".equals(me.getKey()) && !"".equals(me.getValue())){
sql += " and " + me.getKey() + " >= '" + me.getValue() +"'";
}
if("endTime".equals(me.getKey()) && !"".equals(me.getValue())){
sql += " and " + me.getKey() + " }
if("sort".equals(me.getKey()) && !"".equals(me.getValue())){
sql += " order by " + me.getValue() ;
}
if("order".equals(me.getKey()) && !"".equals(me.getValue())){
sql += " " + me.getValue();
}
}
sql += " )t) " ;
sql = sql +" where num >=" + (currentPage-1)*pageSize +" and  num


  接着是MySQL:

String sql = " select * from user  where 1=1 ";

Set> set = m.entrySet();
Iterator io = set.iterator();
while (io.hasNext()) {
Map.Entry me = (Map.Entry) io.next();
if("username".equals(me.getKey()) && !"".equals(me.getValue())){
sql += " and " + me.getKey() + " like '%"+ me.getValue()  +"%'" ;
}
if("startTime".equals(me.getKey()) && !"".equals(me.getValue())){
sql += " and " + me.getKey() + " >= '" + me.getValue() +"'";
}
if("endTime".equals(me.getKey()) && !"".equals(me.getValue())){
sql += " and " + me.getKey() + " }
if("sort".equals(me.getKey()) && !"".equals(me.getValue())){
sql += " order by " + me.getValue() ;
}
if("order".equals(me.getKey()) && !"".equals(me.getValue())){
sql += " " + me.getValue();
}
}
sql = sql +" limit " + (currentPage-1)*pageSize +" , "  + pageSize ;

pageSize 该页有多少条数据,currentPage该页码






相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板