• 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;
    $$
  • 相关阅读:
    jQuery火箭图标返回顶部代码
    jQuery火箭图标返回顶部代码
    jQuery火箭图标返回顶部代码
    jQuery火箭图标返回顶部代码
    jQuery火箭图标返回顶部代码
    HashMap
    反射
    树状数组
    HashCode()函数详解
    容器总结
  • 原文地址:https://www.cnblogs.com/yingsi/p/4517308.html
Copyright © 2020-2023  润新知