Sql Server 2005 分页
生活随笔
收集整理的這篇文章主要介紹了
Sql Server 2005 分页
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
摘要:Sql Server 分頁查詢sql!
Sql Server 2005分頁查詢數(shù)據(jù),適用于手機端和服務器端交互
一:Dao代碼:
/*** 分頁查詢研訊分類下的新聞列表*/@Overridepublic List<TblNews> getListByYunXunNewId(int cId, int start, int limit) {String sql = "select top " + limit+ " * from (select * from dbo.tbl_news where category_id = '"+ cId + "') as a where id not in (select top (" + limit + "*("+ start + "-1)) id from tbl_news where category_id ='" + cId+ "' order by id desc) order by id desc";SQLQuery sqlQuery = this.getSession().createSQLQuery(sql);sqlQuery.addEntity(TblNews.class);return sqlQuery.list();}注釋:其中cId代表新聞分類Id,start代表頁數(shù),limit代表每頁顯示幾條數(shù)據(jù)!
二:SQL語句:
select top 10 * from (select * from tbl_news where category_id = '20') as a where id not in (select top (10*(1-1)) id from tbl_news where category_id='20' order by id desc) order by id desc;總結
以上是生活随笔為你收集整理的Sql Server 2005 分页的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SuperMap iDesktop 9D
- 下一篇: 处理百万级以上的数据提高查询速度的方法