下面一起来了解下Mysql循环如何使用,相信大家看完肯定会受益匪浅,文字在精不在多,希望mysql循环如何使用这篇短内容是你想要的。 while 例如DROP PROCEDURE IF EXIST
下面一起来了解下Mysql循环如何使用,相信大家看完肯定会受益匪浅,文字在精不在多,希望mysql循环如何使用这篇短内容是你想要的。
while 例如
DROP PROCEDURE IF EXISTS zy.test_pro;
DELIMITER $$
CREATE PROCEDURE zy.test_pro(IN id INT)
BEGIN
DECLARE num INT ;
SET num=1;
WHILE num <=id DO
INSERT INTO zy.test VALUES (num,CONCAT('test',num));
SET num = num +1;
END WHILE;
END;
repate
delimiter //
drop procedure if exists looppc;
create procedure looppc()
begin
declare i int;
set i = 1;
repeat
insert into user_profile_company (uid) values (i+1);
set i = i + 1;
until i >= 20
end repeat;
end //
---- 调用
call looppc()
loop
delimiter $$
drop procedure if exists lopp;
create procedure lopp()
begin
declare i int ;
set i = 1;
lp1 : LOOP // lp1 为循环体名称 LOOP 为关键字
insert into user_profile (uid) values (i);
set i = i+1;
if i > 30 then
leave lp1; // 离开循环体
end if; end LOOP; // 结束循环end $$
看完mysql循环如何使用这篇文章后,很多读者朋友肯定会想要了解更多的相关内容,如需获取更多的行业信息,可以关注我们的数据库栏目。
--结束END--
本文标题: mysql循环如何使用
本文链接: https://www.lsjlt.com/news/35046.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-16
2024-05-16
2024-05-16
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0