Mysql储存过程8:repeat循环
Posted FireC@t @ Perl6
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql储存过程8:repeat循环相关的知识,希望对你有一定的参考价值。
语法:
repeat SQL until 条件 end repeat;
就是相当于其他语言中的:
do{ # }while();
mysql> create procedure p1p() -> begin -> declare count int default 0; -> repeat -> select user(); -> set count = count + 1; -> until count>3 end repeat; -> end$ Query OK, 0 rows affected (0.00 sec) mysql> call p1p()$ +----------------+ | user() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.00 sec) +----------------+ | user() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.01 sec) +----------------+ | user() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.01 sec) +----------------+ | user() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.02 sec) Query OK, 0 rows affected (0.02 sec) mysql>
以上是关于Mysql储存过程8:repeat循环的主要内容,如果未能解决你的问题,请参考以下文章