sadier

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::


select top 10 b.* from (select top 20 主键字段,排序字段 from 表名 order by 排序字段 desc) a,表名 b where b.主键字段 = a.主键字段 order by a.排序字段

10 = 每页记录数

20 = (当前页 + 1) * 每页记录数


1。用next()方法,
选从50-100行
int CurrentRow = 1;
int MinRow = 50;
int MaxRow = 100;
while(rs.next())
{
if (CurrentRow {
CurrentRow++;
continue;
}
}
2.用absolute(int row)定位
先定位到50行,然后next();
3.用sql完成
SqlServer的语句:select top 50 * from (select top 100 * from sysobjects order by id) as a order by id desc
Oracle的语句:
select * from (select rownum r ,* from test) ss
where ss.r > 50 and ss.r <= 100;
测试速度 :
absolute()最慢;定位到10000条以后无法忍受!
next();前面几条快,越往后越慢!
SqlServer语句,比next快很多,但也是越往后越慢!
Oracle语句,最快!几乎不受条数影响!

posted on 2004-11-23 13:53  毛小华  阅读(1401)  评论(0编辑  收藏  举报