mysql 存储过程中limit(#1064 You have an error in your SQL syntax)

转载地址:点击打开链接

如下:

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 ;

你可能感兴趣的:(MySQL)