欢迎来到LYBLaoInB的博客
LYBLaoInB
LYBLaoInB
回首往事,不因虚度年华而悔恨,不因碌碌无为而愧疚

存储过程中的逻辑语句

第一种:

if()

then 

else 

end if 

---------------------------------------------------------------------------------------------

第二种

if()

then 

elseif()

then

else

end if

----------------------------------------------------------------------------------------------------

第三种 while循环

delimiter $$
CREATE procedure insertNum()
begin
DECLARE i int default 0;
while(i<10) do
begin
set i=i+1;
insert into tbl_num (id) values (i);
END ;
end while;
end;
$$

调用后就可以循环向表中插入10条数据了注意,这个语法中每个end都需要;结尾的

结构应该是 while() do begin xxx要做的逻辑 end; end while;

-----------------------------------------------------------------------------------------------

第四种repeat循环

begin
DECLARE i int default 101;
repeat
begin
set i=i+1;
insert into tbl_num values (i);
END ;
until i >110
end repeat;
end

语法:repeat begin xxx逻辑处理 end until 某个逻辑表达式 end repeat;

 

posted @ 2019-06-11 15:21  LiuYongbo  阅读(599)  评论(0)    收藏  举报
<--将网易云歌单中的id复制到上面的data-id中就可以了 http://music.163.com/playlist?id=3103841025&userid=1698529278 -->