oracle和mysql实现分页查询(转载)

oracle实现分页查询
使用伪劣rownum实现分页查询

//可以运行
select rownum from emp where rownum<6;
//不可以运行
select rownum from emp where rownum>6;
//不可以运行,无结果
select rownum from emp where rownum<6 and rownum>3;

//例题 假设每页显示3条,查询出第二页
查不出
select * from (select emp.,rownum from emp) ee where ee.rownum>3 and ee.rownum<7;
可以查出(要给伪列rownum设置别名)
select * from (select emp.
,rownum rn from emp) ee where ee.rn>3 and ee.rn<7;

select * from (select emp.*,rownum rn from emp) where rn>3 and rn<7;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
在这里插入图片描述

mysql实现分页查询

#查询前五条学生信息
SELECT * FROM students LIMIT 0, 5;
#如果你要查询的数据,是从第一条数据开始的,那么0可以省略,如下:
SELECT * FROM employees LIMIT 5;

#案例2:查询第11条到第25条(起始索引从10开始,显示15条)
SELECT * FROM students LIMIT 10, 15;

使用sql关键字limit
limit 参数1,参数2
参数1 从该位置开始查(不写默认从头开始查)
参数2 查询多少条数据

原文链接:https://blog.csdn.net/qq_41150890/article/details/107674864?utm_medium=distribute.pc_feed.none-task-blog-personrec_tag-9.nonecase&depth_1-utm_source=distribute.pc_feed.none-task-blog-personrec_tag-9.nonecase&request_id=5f21e6278c9fb674c67219f0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值