passing LIMIT as parameters to MySQL sproc

前端 未结 7 667
遥遥无期
遥遥无期 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:12

    The following worked just fine in MySQL 5.5.35. It also worked in another procedure where the same SELECT was used within a DECLARE . . . CURSOR statement.

    CREATE PROCEDURE `test`(
      IN `lim_val` INT,
      IN `lim_offset` INT
    )
    BEGIN
      SELECT array_ident_id
        FROM ArrayIdents
        ORDER BY array_ident_id
        LIMIT lim_val OFFSET lim_offset;
    END;
    

提交回复
热议问题