Can I run a loop in MySQL without using a procedure/function?

后端 未结 4 1053
Happy的楠姐
Happy的楠姐 2021-02-18 13:39

For testing, is it possible to run a loop from MySQL workbench or similar tool? I tried but got an error.

If it is possible, please supply a simple example I can run.

4条回答
  •  不要未来只要你来
    2021-02-18 14:28

    Supposed that you already have an arbitrary table myOldTable which is sufficiently long you could use the following trick:

    set @counter = 0;
    select (@counter := @counter+1), @counter*@counter from myOldTable limit 1000;
    

提交回复
热议问题