SQL之查询某几行记录--分页查询
来源:互联网 发布:java系统性能监控 编辑:程序博客网 时间:2024/05/17 04:00
ORACLE:
1、查询前10行:select * from sc_objects where rownum <=10
2、利用minus
查询10到20行:select * from sc_objects where rownum <=20 minus select * from sc_objects where rownum <=10;
查询20行之后:select * from sc_objects minus select * from sc_objects where rownum <=20;
3、常用于分页查询:
PAGESIZE:每页显示的记录数
CURRENTPAGE:当前页号
数据表的名字是:components
索引主键字是:id
select * from components where id not in(select id from components where rownum<=(PAGESIZE*(CURRENTPAGE-1))) and rownum<=PAGESIZE order by id;
如下例:
select * from sc_objects where id not in(select id from sc_objects where rownum<=100) and rownum<=10 order by id;
4、一种是利用Oracle的rownum,这个是Oracle查询自动返回的序号,一般不显示,但是可以通过select rownum from [表名],可以看到,是从1到当前的记录总数。
select * from (select rownum tid,components.* from components where rownum<=100) where tid<=10;
MYSQL和sqLite:
查询n+1到m行: select * from tadd order by id limit n,m;
示例:
select * from tadd order by id limit 4 offset 2;
select * from tadd order by id limit 2,4;
SQLSERVER:
select top 5 * from sc_objects where id not in(select top(当前页-1)*5) id from sc_objects;
http://blog.163.com/zsclei@126/blog/static/3192610020082118334267/
引申between and 的用法
http://blog.sina.com.cn/s/blog_8ce459cd0101meyp.html
- SQL之查询某几行记录--分页查询
- SQL之分页查询
- SQL 单表多条记录分组查询分页代码
- 记录--sqlite 分页查询
- SQL之通用查询分页存储过程
- SQL之通用查询分页存储过程
- SQL on HBase -- phoenix 之分页查询
- SQL语言(2)之分页查询
- SQL on HBase -- phoenix 之分页查询
- mybatis分页查询之sql server--mysql
- SQL 查询分页,排序后分页查询
- SQL分页查询优化
- 一个分页查询sql
- SQL分页数据查询
- Sql分页查询
- 分页查询SQL语句
- sql分页查询语句
- sql分页查询
- 工作还是学习,是个问题
- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- redis配置文件redis.conf详细说明
- java.io.IOException: Negative seek offset
- Ueditor编辑器的使用
- SQL之查询某几行记录--分页查询
- ArcGIS API for Windows phone网站
- javascript--单例模式
- 滤波
- 每个程序员1小时内必须解决的5个编程问题
- HDU - 4712 Hamming Distance(坑爹的随机数算法 + 暴力求解)
- Linux 内核学习之内存寻址(一) 硬件寻址
- Unreal Engine 4 Terminology
- for (int i = 0; gc_handDataOutput->QueryNumberOfHands(); ++i)