select * from
(
select my_table.*,rownum as my_rownum from
(Select comment_info,comment_id,comment_time,user_id,data_id,user_ip from
t_user_comment where data_id=11111111 order by comment_id desc)
my_table where rownum<= 3)
where my_rownum>= 1;
select my_table.*,rownum as my_rownum from
(Select comment_info,comment_id,comment_time,user_id,data_id,user_ip from
t_user_comment where data_id=11111111 order by comment_id desc)
my_table where rownum<= 3)
where my_rownum>= 1;
解释:
select * from
(
select my_table.*,rownum as my_rownum from
//上面固定
(Select 列,……from 表 where 条件 and / or …… order by 字段 desc/asc
my_table where rownum<= 结束的值)
where my_rownum>= 开始的值;
博客主要对Oracle数据库中的SQL分页查询语句进行了解释。给出了具体的SQL语句结构,包括嵌套查询,通过rownum实现分页,先筛选出小于等于结束值的记录,再从这些记录中选取大于等于开始值的记录。
31万+

被折叠的 条评论
为什么被折叠?



