項目介紹: 評論分頁存儲過程
項目背景:asp.net(c#) +sql2005
存儲過程代碼:
以下為引用的內容: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: zhaoyang -- Create date: 2009-8-21 -- Description: 顯示用戶評論列表 -- ============================================= CREATE PROCEDURE [dbo].[CommentShowList_zy] @GeneralID int, --信息ID @ParentID int, --父ID @OrderFlag int, --排序標示 0標示最新 1標示熱門 @CurrentPage int, --當前頁碼 @pagesize int --每頁的數據條數 AS BEGIN IF(@ParentID=0) --讀取評論內容 BEGIN IF(@OrderFlag=0) BEGIN with a as( select *,px=row_number() over(order by id desc) from cms_wangpiao.dbo.Comment_zy where GeneralID=@GeneralID and ParentID=@ParentID ) select * from a where px BETWEEN(@CurrentPage-1)* @pagesize+1 and @CurrentPage* @pagesize END IF(@OrderFlag=1) BEGIN with b as( select * ,px=row_number() over(order by a.CountReply desc ) from ( select *,(select count(0) from Comment_zy czb where czb.ParentID=cza.id) as CountReply from Comment_zy cza where GeneralID=@GeneralID and ParentID=@ParentID ) a ) select * from b where px BETWEEN (@CurrentPage-1)* @pagesize+1 and @CurrentPage* @pagesize END END ELSE--讀取評論回復內容 BEGIN select * from cms_wangpiao.dbo.Comment_zy where ParentID=@ParentID ORDER BY id desc END END |
來自:http://www.cnblogs.com/studyplay/
上一篇 關于工信部備案當面核驗方案的擔憂