mysql 常见的几种循环
#loop ... end loop
DECLARE i INT DEFAULT 0;
repeat_label:LOOP
SELECT i;
SET i=i+1;
IF i>=5 THEN
LEAVE repeat_label;
END IF;
END LOOP;
SELECT '测试外面是否执行';#答案:会,leave只是跳出循环
# while 条件 do ... end while
WHILE i<=2 DO
SELECT CONCAT('你好',i);
SET i=i+1;
END WHILE;
# repeat ... until 条件(后面不能加结束符) end repeat
REPEAT
SET i=i+1;
SELECT i;
UNTIL i<=2
END REPEAT;