Mysql procedure loop with step
Please be aware that I am learning MySQL as my application continues to grow. Please keep this in mind if you are kind enough to answer my question.
I am trying to achieve the following
I added a new row to the table, keeping track of the game number in the round, this way it will have values 1,2,3,4 .... when the round ends it will be reset to 1, etc.
I read in the MySQL manual about loops and came up with this, however it says my syntax is wrong, I would appreciate it if a more experienced user could consider this for me.
CREATE PROCEDURE inc()
BEGIN
DECLARE v1 INT
WHILE `round` ='1'
SET v1 = v1 + 1;
update events set `round_game_nr` ='v1'
END WHILE;
END;
I am trying to achieve this
, where the 1st column is round, and the second column is nr games
+3
source to share