注意
不能对rownum使用>(大于1的数值)、>=(大于或等于1的数值)、=(大于或等于1的数值),否则无结果,所以直接用只能从1开始。
rownum>10没有记录,因为第一条不满足去掉的话,第二条rownum又成了1,所以永远没有满足条件的记录。
select * from student where rownum>=1;
如果想要rownum不从1开始,需按下面方法使用
select a.* from (select student.*,rownum rn from student) a
where rn>5;
分页查询1:
select * from (select a1.* ,rownum rn from (select * from student)a1 where rownum<=5)
where rn>=2;
分页查询2:
select a1.* from (select student.*,rownum rn from student where rownum<=5) a1
where rn>=3
分页查询3:
select a1.* from(select student.*,rownum rn from student) a1
where rn between 2 and 5;