用oracle在mybatis中分页sql怎么写
1个回答
展开全部
(1)
select *
from (select a.*, rownum rnum
from (select id, data
from t order by id, rowid) a
)
where rnum >= 148 and rnum<=151;
或者
(2)
select *
from (select a.*, rownum rnum
from (select id, data
from t order by id, rowid) a
where rownum <= 151 )
where rnum >= 148;
最近在开发中同事说第(1)种效率不好,而第(2)种在只有唯一值(列)的时间才能正常排序,以前一直用第(1)种,今天同事找到如下的方式,解决了 第(2)种唯一值(列)排序的问题,如下:
(3)
select *
from (select a.*, rownum rnum
from (select id, data
from t order by id, rowid) a
where rownum <= 151 )
where rnum >= 148;
select *
from (select a.*, rownum rnum
from (select id, data
from t order by id, rowid) a
)
where rnum >= 148 and rnum<=151;
或者
(2)
select *
from (select a.*, rownum rnum
from (select id, data
from t order by id, rowid) a
where rownum <= 151 )
where rnum >= 148;
最近在开发中同事说第(1)种效率不好,而第(2)种在只有唯一值(列)的时间才能正常排序,以前一直用第(1)种,今天同事找到如下的方式,解决了 第(2)种唯一值(列)排序的问题,如下:
(3)
select *
from (select a.*, rownum rnum
from (select id, data
from t order by id, rowid) a
where rownum <= 151 )
where rnum >= 148;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询