且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在MySQL语句中使用嵌套循环和变量

更新时间:2023-01-19 20:18:42

不幸的是,您不能在存储程序之外使用LOOP:存储过程,存储函数和触发器.

Unfortunately you can't use LOOP outside of a stored program: stored procedures, stored functions, and triggers.

您确实有一些选择:

  1. 您可以创建存储过程并限制特权,以便其他用户无法执行它.
  2. 另一种选择是在脚本中临时创建一个存储过程,运行它,然后将其放在脚本末尾.

否则,如果您仍然不想创建存储过程,那么***的选择是用shell,python等编写一个小的脚本来进行循环.

Otherwise, if you still don't want to create a stored procedure, your best bet is to write a small script in shell, python, etc to do your looping.

祝你好运!