zoukankan      html  css  js  c++  java
  • 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;
    $$
  • 相关阅读:
    模型绑定功能
    接口返回的内容
    跨平台的ASP.NET Core简介
    NLog如何打印日志(.Net5)
    注意力创造价值;
    Restful接口的介绍
    电脑设置双屏显示(windows)
    Linq多集合连接
    调试时才执行的代码
    mvc4 路由匹配测试
  • 原文地址:https://www.cnblogs.com/yingsi/p/4517308.html
Copyright © 2011-2022 走看看