mysql loop with variable incrementing

I added a new row to my table, keeping track of the game number in the round, thus it will have values 1,2,3,4.... when round ends it will be reset to 1 etc

it will be pretty simple to code this with php or similar just doing

$x=1++
while(round == 1){
INSERT INTO events (game_nr) values ('$x')
$x++
}

Is there something similar I can use as the above code on a mysql db using only mysql?


阅读mysql中的手动定义变量

SET @x := 1; -- Define a variable
INSERT INTO events (game_nr) values (@x := @x + 1)
链接地址: http://www.djcxy.com/p/26332.html

上一篇: 如何调用存储过程并在Slick中获取返回值(使用Scala)

下一篇: mysql循环与变量递增