当前位置: 代码迷 >> Java Web开发 >> 改成oracle分页语句.如何改求解。
  详细解决方案

改成oracle分页语句.如何改求解。

热度:1627   发布时间:2013-02-25 21:12:27.0
改成oracle分页语句.....怎么改求解。。。。
String sql = "select top 20 * from TBL_TOPIC where boardId=" + boardId + " and topicId not in(select top "+ rowBegin + " topicId from TBL_TOPIC where boardId=" + boardId + " order by publishTime desc )order by publishTime desc";

------解决方案--------------------------------------------------------
select m.* from (select x.*,rownum r from (select z.* from zzg z where z.score<60 order by score) x) m where m.r>2 and m.r<4
类似这样试试
------解决方案--------------------------------------------------------
select * from (
select id , pid , rootid ,title ,con ,pdate ,isleaf, rownum r ,virtualDatefrom
(select * from article where pid = 0 order by pdate desc)
)where r >= 4 and r <= 8;类似这样的
article表如下:
create table article
(
 id number primary key,//id号
 pid number,//父节点
 rootid number,//根节点
 title varchar2(256),//标题
 con varchar2(1000),//内容
 pdate date,//时间
 isleaf number --1代表非叶子,0代表叶子
virtualDate date default Sysdate--用来flat中的排序,当有人回复主题帖时其值会改变,只有root节点才会有实在的virtualDate
)
------解决方案--------------------------------------------------------
select nid,ntitle,nauthor from ( 
select nid,ntitle,nauthor,row_number() over ( order by nid desc ) rn from news order by nid desc 
)
where rn between 41 and 50;

nid和ntitle是列名, row_number()是虚拟列
------解决方案--------------------------------------------------------
SQL code
select * from (select rownum,name from table where rownum <=endIndex ) where rownum > startIndex
  相关解决方案