在sql2005以上的版本中可以用如下代碼: [sql] www.2cto.com <a href="mailto:--@PageNo">--@PageNo</a> 是頁碼(要查詢第幾頁),@pageSize是頁容量(即每頁顯示多少條數(shù)據(jù)) [sql] select * from ( select row_number() over(order by id) rn,* from Test) tb where rn >(@PageNo-1)*@pageSize and rn <=@PageNo*@pageSize 以上只是簡單的分頁,如果還有其他邏輯,比如排序 可以在over中加入排序的方法 test表 也可以換成子查詢等其他邏輯 www.2cto.com 在oracle中,可以使用如下語句 [sql] select t2.* from (select rownum r,t1.* from test t1 where rownum<=:PageNo*:pageSize) t2 where t2.r>(:PageNo-1)*:pageSize