• mysql 循环


    DELIMITER $$
    DROP PROCEDURE IF EXISTS student_insert_while;
    $$
    create procedure student_insert_while(in username varchar(45), in birthday date, in age int)
    begin
        declare i int default 0;
        while i < 10 do
            insert into student (username, birthday, age) values(concat("abc", i), sysdate(), i);
            set i = i + 1;
        end while;
    end;
    $$
    
    DELIMITER ;
    
    DELIMITER $$
    DROP PROCEDURE IF EXISTS student_insert_repeat;
    $$
    create procedure student_insert_repeat(in username varchar(45), in birthday date, in age int)
    begin
        declare i int default 0;
        repeat
            insert into student (username, birthday, age) values(concat("abc", i), sysdate(), i);
            set i = i + 1;
            until i >= 5
        end repeat;
    end;
    $$
    
    DROP PROCEDURE IF EXISTS student_insert_loop;
    $$
    create procedure student_insert_loop(in username varchar(45), in birthday date, in age int)
    begin
        declare i int default 0;
        loop_label:loop
            insert into student (username, birthday, age) values(concat("abc", i), sysdate(), i);
            set i = i + 1;
            if i >= 5 then
                leave loop_label;
            end if;
        end loop;
    end;
    $$
  • 相关阅读:
    HDU_1242_Rescue
    HDU_1175_连连看
    HDU_1072_Nightmare
    HDU_2544_最短路
    POJ_2195_Going Home
    POJ_3565_Ants
    KM算法(Kuhn-Munkres)
    POJ_2536_Gopher II
    ODATA 云驱动 http://www.cdata.com/cloud/
    Wijmo 5 与Breeze 的组合,及与METRONIC 的集成
  • 原文地址:https://www.cnblogs.com/yingsi/p/4517308.html
Copyright © 2020-2023  润新知