select *
from (select c.*, rownum rn from content c)
where rn >= 1
and rn <= 5 優化
2. 可是若是, 加上order by addtime 排序則數據顯示不正確 排序
select *
from (select c.*, rownum rn from content c order by addtime)
where rn >= 1
and rn <= 5 it
解決方法,再加一層查詢,則能夠解決, 效率
select *
from (select rownum rn, t.*
from (select title, addtime from content order by addtime desc) t)
where rn >= 1
and rn <= 5 select
若是要考慮到效率的問題,上面的還能夠優化成(主要二者區別) 分頁
select *
from (select rownum rn, t.*
from (select title, addtime from content order by addtime desc) t
where rownum <= 10)
where rn >= 3 方法