MSSQL根据ID进行分页实现方法

本文将详细介绍MSSQL根据ID进行分页实现方法,需要的朋友可以参考下

复制代码 代码如下:

ALTER PROCEDURE [a0919194122].[dnt_getappinvitelist]
@uid int,
@pageindex int,
@pagesize int
AS
DECLARE @startRow int,
@endRow int
SET @startRow = (@pageIndex - 1) * @pagesize
IF @pageindex = 1
BEGIN
EXEC(
'SELECT TOP '+@pagesize+' [id],[typename],[appid],[type],[fromuid],[touid],[myml],[datetime],[hash] FROM [dnt_myinvite] WHERE [touid]='+@uid+' ORDER BY [id] DESC'
)
END
ELSE
BEGIN
EXEC('
SELECT
TOP '+@pagesize+'
[id],[typename],[appid],[type],[fromuid],[touid],[myml],[datetime],[hash]
FROM [dnt_myinvite]
WHERE [touid]='+@uid+'
AND [id] <(SELECT MIN([id]) FROM (SELECT TOP '+@startRow+' [id]
FROM [dnt_myinvite]
WHERE [touid]='+@uid+'
ORDER BY [id] DESC
) AS T
)
ORDER BY [id] DESC
')
END

以上就是MSSQL根据ID进行分页实现方法的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 数据库