ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

mysql (:kabel_name:loop...end loop"; "repeat....end repeat";"while ... do .... e

2020-06-06 19:06:38  阅读:100  来源: 互联网

标签:test1 ... set end car1 while repeat myarticle


drop PROCEDURE if exists test1;
create procedure test1()
begin
    declare i int;
    set i=1;
while i<=30 do
        update blog.car1_myarticle 
        set blog.car1_myarticle.brief_content=i
        where car1_myarticle.id=i;
        set i=i+1;
end while;
end;
----------------------------------------
drop PROCEDURE if exists test1;
create procedure test1()
begin
    declare i int;
    set i=1;
exit_a:loop  -- 定义一个标签为 "exit_a"
        update blog.car1_myarticle 
        set blog.car1_myarticle.brief_content=i
        where car1_myarticle.id=i;
        set i=i+1;
    if i>30 THEN
        LEAVE exit_a;  -- 离开指定的标签 "exit_a"
    end if;
end loop;
end;
----------------------------------------
drop procedure if EXISTS test1;
create procedure test3()
begin
    declare i,n int;
    set i=1;
    set n=30;
REPEAT
            update blog.car1_myarticle 
            set blog.car1_myarticle.brief_content=i
            where car1_myarticle.id=i;
set i=i+1;
until i>n
end REPEAT;
end;

 

标签:test1,...,set,end,car1,while,repeat,myarticle
来源: https://www.cnblogs.com/vmsysjack/p/13055978.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有