刚开始犯了一个错误,我把mysql的分页查询语句拿到oracle中进行查询,找了大半天没有找到原因,后来突然意识到自己使用的是oracle。。。。
随后,学习了一下oracle的分页是怎么使用的:
1、查询前n条数据,使用rownum:
不排序:
SELECT * FROM table_name where rownum < n
排序:
SELECT * FROM (
SELECT * FROM table_name ORDER BY field DESC
) where rownum < n
2、查询n条到m条的记录:
select * from (
select t.*, rownum as no from
(select * from table_name order by field desc) t
)where no between n and m
3、查询n条以后的数据:
select * from
(select t.*, rownum as no from
(select * from table_name order by field desc) t
)where no >=n