转载地址:点击打开链接
如下:
delimiter //
create procedure getFNCommentView(
in pNoteID int,
in startRow int,
in pagesize int
)
begin
set @rowcount = (
select count(*) from Forumnotecomment
where FNID = pNoteID
);
set @SQLStr=CONCAT('select FNCommentID, Forumnotecomment.UserID, Content, Forumnotecomment.CreateTime, `from` as fromUser, `to` as toUser, isUseful, isUseles, isSupport, isOppose, isPraise, replayNav,NoteID,toUsers.UserType as toUserType,toUsers.UserName as toUserName,Users.UserType,Users.UserName,Users.avatar,@rowcount as rowcount
from Forumnotecomment
inner join Forumnote on Forumnotecomment.FNID=Forumnote.NoteID
inner join Users as toUsers on Forumnotecomment.`to`=toUsers.UserID
inner join Users on Forumnotecomment.UserID=users.UserID
where Forumnotecomment.FNID=',pNoteID,' order by Forumnotecomment.CreateTime limit ',startRow,pagesize);
PREPARE stmt from @SQLStr;
EXECUTE stmt;
end //
delimiter ;
本文介绍了一个用于数据库的存储过程,该过程用于获取指定论坛帖子的评论列表,并支持分页查询。通过输入帖子ID、起始行数及页面大小等参数,可以有效地检索和展示评论数据。
1万+

被折叠的 条评论
为什么被折叠?



