Oracle、MySQL和Sql Serve三种数据库分页查询语句的区别介绍

栏目: 数据库 · Mysql · SQL Server · Oracle · 发布时间: 8年前

内容简介:这篇文章主要介绍了Oracle、MySQL和SqlServe三种数据库分页查询语句的区别介绍 的相关资料,需要的朋友可以参考下

这篇文章主要介绍了OracleMySQLSql Serve三种数据库分页查询语句的区别介绍 的相关资料,需要的朋友可以参考下

先来定义分页语句将要用到的几个参数:

int currentPage ; //当前页  
int pageRecord ; //每页显示记录数  

以之前的ADDRESSBOOK数据表为例(每页显示10条记录):

**一、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)

二、 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

三、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

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Coding the Matrix

Coding the Matrix

Philip N. Klein / Newtonian Press / 2013-7-26 / $35.00

An engaging introduction to vectors and matrices and the algorithms that operate on them, intended for the student who knows how to program. Mathematical concepts and computational problems are motiva......一起来看看 《Coding the Matrix》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具