Oracle、MySQL和SqlServe分页查询的语句区别
时间:2021-07-01 10:21:17
帮助过:3人阅读
- int currentPage ; //当前页
- int pageRecord ; //每页显示记录数
以之前的ADDRESSBOOK数据表为例(每页显示10条记录):
一、SqlServe下载 数据库分页语句
Java代码
-
String sql = "select top "+pageRecord +" * from addressbook where id not in (select top "+(currentPage-1)*pageRecord +" id from t_user)";
-
第二页SQL演示:
select top 20 * from addressbook where id not in (select top 10 id from addressbook)
二、MySQL数据库分页语句
Java代码
-
String sql = "select * from addressbook where limit "+(currentPage-1)*pageRecord +","+pageRecord +"";
-
-
-
-
第二页SQL演示:
select * from addressbook where limit 10,10
三、Oracle数据库分页语句
Java代码
-
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分页查询的语句区别
标签: