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();

 

相关文章:

  • 2021-07-25
  • 2022-01-05
  • 2022-02-02
  • 2022-12-23
  • 2022-03-13
  • 2021-10-26
  • 2021-08-24
  • 2022-12-23
猜你喜欢
  • 2022-01-09
  • 2021-07-27
  • 2022-12-23
  • 2021-10-18
  • 2021-04-13
  • 2021-10-10
  • 2022-12-23
相关资源
相似解决方案