syntax error for mysql declaration of variable

前端 未结 2 1700
野的像风
野的像风 2020-12-29 04:26
CREATE PROCEDURE dorepeat(IN p1 INT)
BEGIN
  DECLARE x INT DEFAULT 0;
  REPEAT SET x = x + 1; UNTIL x > p1 END REPEAT;
END

I get an syntax error

2条回答
  •  Happy的楠姐
    2020-12-29 04:38

    Remove the DECLARE, you should be able to just do this:

    SET @x = 0;
    

    Also, variables need to be prefixed with the @ symbol

提交回复
热议问题