本文共 601 字,大约阅读时间需要 2 分钟。
drop procedure if exists p_update_platform; delimiter $$ create procedure p_update_platform(in p_platform_id int,in p_platform_name varchar(50),in p_shop_id int,out p_num int) begin set p_num=1; WHILE exists(select 1 from sale_order where shop_id=p_shop_id and platform_id is null) and p_num<=10 do update sale_order set platform_id=p_platform_id,platform_name=p_platform_name where shop_id=p_shop_id and platform_id is null limit 1; set p_num=p_num+1; end while ; end ; $$ delimiter ; set @platform_id=1010,@platform_name='天猫',@shop_id=35; call p_update_platform(1010,'天猫', 35,@p_num); select @p_num;转载地址:http://slfmi.baihongyu.com/