日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 存储过程 显示控制_mysql存储过程之控制语句篇

發(fā)布時間:2025/4/5 数据库 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 存储过程 显示控制_mysql存储过程之控制语句篇 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

loop的使用 要結(jié)合leave 和 iterate

看到名字 都已經(jīng)大概 猜測到了 意思

leave 就是離開退出循環(huán) 而 iterate就是 繼續(xù)迭代

CREATE PROCEDURE ABC()

BEGIN

DECLARE a INT Default 0 ;

simple_loop: LOOP

SET a=a+1;

select a;

IF a=5 THEN

LEAVE simple_loop;

END IF;

END LOOP simple_loop;

END

create procedure pro

begin

declare a int default 1;

label1: loop

if a<6 then

select a;

set a=a+1;

iterate label1;

end if;

leave label1;

end loop label1;

end

3.REPEAT[begin_label:] REPEAT

statement_list

UNTIL search_condition

END REPEAT [end_label]

REPEAT語句內(nèi)的語句或語句群被重復,直至search_condition為真。

create procedure pro

begin

declare a int default 3;

repeat

select a;

set a=a+1;

untile a>5 end repeat;

end

4.while

[label:] WHILE 條件 DO--循環(huán)處理END WHILE [label];

create procedure pro

begin

declare a int default 4;

while a<10 do

select a;

set a=a+1;

end while;

end

下面是一個摘抄的例子,主要看while如何使用

WHILE (id is not null ) DO

if(month='01'||month='02'||month='03') THEN set season='1';

end if;

if(month='04'||month='05'||month='06') THEN set season='2';

end if;

if(month='07'||month='08'||month='09') THEN set season='3';

end if;

if(month='10'||month='11'||month='12') THEN set season='4';

end if;

update t_industry_finance_instance set season_=season where ID_=id;

FETCH cur1 INTO id,month;

END WHILE;

總結(jié)

以上是生活随笔為你收集整理的mysql 存储过程 显示控制_mysql存储过程之控制语句篇的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。