我的真假分頁
阿新 • • 發佈:2018-11-10
在我所遇到的分頁有兩種真分頁和假分頁
假分頁:適用於一般資料不多的情況在資料庫取到所有值後在後臺經行拆分
利:簡單 訪問次數較少 弊:處理不了較大的資料
真分頁:一般企業資料較多的查詢用到 每次都去資料庫取出該少量資料(當前分頁的資料)
從而避免資料過大記憶體溢位
利:資料量小 弊:訪問次數過於頻繁 sql語句較為複雜
真分頁:select b.* from(
select a.*,rowunm rn from(
select t.列名1,
t.列名2,
t.列名3,
t.列名4,
t.列名5
from 表名 t
where 1=1
<if test='列名1!="" and 列名1!=null'>
條件 and t.列名1 = #{(傳入的值對應列名1)}
</if>
<if test='列名2!="" and 列名2=null'>
條件 and t.列名 = #{(傳入的值對應列名 )}
</if>
) a where rownum <=#{max(傳入的最大值)}
) b where rn > #{min(傳入的最小值)}