mysql存储过程造数据取一个基准用户的各种类型都取一条数据作为基准数据,循环插入

时间:2021-09-02 01:27:27
 CREATE DEFINER=`user`@`%` PROCEDURE `create_upload_data`(in start_userid integer,in create_counter integer)
BEGIN
declare i integer;
set i = start_userid;
while i < start_userid + create_counter do
insert into t_xx_table(column1,column2,column3,column4)
select i,column2,column3,column4 from t_xx_table t1 where column1=1814840 and 1 >(
select count(*) from t_xx_table where column1=t1.column1 and column2=t1.column2 and column3>t1.column3) ;
set i = i+1;
end while;
END
CREATE DEFINER=`root`@`%` PROCEDURE `delete_user_procedure`(in p_mobile bigint,in p_counter bigint)
BEGIN
DECLARE p_user_id bigint ;
DECLARE i bigint ;
set i = p_mobile;
while i < p_mobile + p_counter do
select id into p_user_id from test.t_user where mobile=p_mobile;
delete from test.t_user_action where user_id=p_user_id;
set i = i + 1 ;
end while;
END