MSSQL根据ID进行分页实现方法
时间:2021-02-22 17:58:49|栏目:Mysql|点击: 次
复制代码 代码如下:
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
上一篇:MySQL从命令行导入SQL脚本时出现中文乱码的解决方法
栏 目:Mysql
下一篇:mysql 列转行的技巧(分享)
本文标题:MSSQL根据ID进行分页实现方法
本文地址:http://www.codeinn.net/misctech/67519.html