您的位置:首页 > 数据库 > SQL

【MySQL】MySQL PLSQL Demo - 006.循环(WHILE DO and FOR LOOP)

2015-09-12 01:30 621 查看

WHILE DO

drop procedure if exists p_while_do;

create procedure p_while_do()
begin
declare i int;
set i = 1;
while i <= 10 do
select concat('index : ', i);
set i = i + 1;
end while;
end;

call p_while_do();


FOR LOOP

drop procedure if exists p_for_loop;

create procedure p_for_loop()
begin
declare i int;
set i = 1;
loop_example : loop
select concat('index -> ', i);
set i = i + 1;

if i > 10 then
leave loop_example;
end if;
end loop;
end;

call p_for_loop();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: