passing LIMIT as parameters to MySQL sproc

前端 未结 7 684
遥遥无期
遥遥无期 2020-11-29 09:59

I\'m creating a paging class and need to pass in two parameters to my MySQL stored procedure for the LIMIT clause.

I\'m passing them in as INTs and trying something

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 10:10

    pagination without statements:

    create PROCEDURE test(
      IN first_rec integer,
      IN rec_count integer
    )
    BEGIN
      -- return --
      SET @rownum=0;
      SELECT * FROM (
        SELECT
        user.*, @rownum:=@rownum+1 AS rn FROM user
      ) t WHERE rn>=first_rec and rn

提交回复
热议问题