概述
三国纷争
MySQL中的while循环语法示例:delimiter //CREATE procedure yourdatabase.while_example()wholeblock:BEGIN declare str VARCHAR(255) default ''; declare x INT default 0; SET x = 1; WHILE x <= 5 DO SET str = CONCAT(str,x,','); SET x = x + 1; END WHILE; select str;END//哪些打印:mysql> call while_example();+------------+| str |+------------+| 1,2,3,4,5, |+------------+MySQL中的REPEAT循环语法示例:delimiter //CREATE procedure yourdb.repeat_loop_example()wholeblock:BEGIN DECLARE x INT; DECLARE str VARCHAR(255); SET x = 5; SET str = ''; REPEAT SET str = CONCAT(str,x,','); SET x = x - 1; UNTIL x <= 0 END REPEAT; SELECT str;END//哪些打印:mysql> call repeat_loop_example();+------------+| str |+------------+| 5,4,3,2,1, |+------------+MySQL中的FOR循环语法示例:delimiter //CREATE procedure yourdatabase.for_loop_example()wholeblock:BEGIN DECLARE x INT; DECLARE str VARCHAR(255); SET x = -5; SET str = ''; loop_label: LOOP IF x > 0 THEN LEAVE loop_label; END IF; SET str = CONCAT(str,x,','); SET x = x + 1; ITERATE loop_label; END LOOP; SELECT str;END//哪些打印:mysql> call for_loop_example();+-------------------+| str |+-------------------+| -5,-4,-3,-2,-1,0, |+-------------------+1 row in set (0.00 sec)进行本教程:http : //www.mysqltutorial.org/stored-procedures-loop.aspx如果我发现您将这种MySQL for循环构造推入生产,那么我将用泡沫导弹发射器向您射击。您可以使用管扳手敲打钉子,但是这样做会使您看起来很傻。
最后
以上就是幸福大门为你收集整理的mysql的for循环_MySQL中的For循环示例的全部内容,希望文章能够帮你解决mysql的for循环_MySQL中的For循环示例所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复