码迷,mamicode.com
首页 > 数据库 > 详细

Oracle分页

时间:2019-02-25 13:38:48      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:--   方法   and   大于   使用   student   sele   等于   rownum   

-- 不能对ROWNUM使用>(大于1的数值)、>=(大于或等于1的数值)、=(等于1的数值),否则无结果
-- 所以直接用只能从1开始
-- rownum >10 没有记录,因为第一条不满足去掉的话,第二条的rownum又成了1,所以永远没有满足条件的记录。
select * from student where rownum>=1;

--如果想要用rownum不从1开始,需按下面方法使用
select a1.* from (select student.*,rownum rn from student) a1 where rn >5;


--分页查询一
select * from (select a1.*,rownum rn from (select * from student) a1 where rownum <=5) where rn>=2;

--分页查询二
select a1.* from (select student.*,rownum rn from student where rownum <=5) a1 where rn >=3;

--分页查询三
select a1.* from (select student.*,rownum rn from student) a1 where rn between 3 and 5;

Oracle分页

标签:--   方法   and   大于   使用   student   sele   等于   rownum   

原文地址:https://www.cnblogs.com/ChenBingJie123/p/10430339.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!