如何使用MySQL实现批量插入数据
2个回答
展开全部
用存储过程,写个循环给你个我以前写的看看
begin
declare i int;
declare b int;
declare c int;
set @i=2;
set @b=6;
set @c=0;
set @stmt = concat('insert into t_j_goods_name (id,`code`,`name`)
values(?,?,(select distinct `a` from sheet1 limit ?, 1))');
while @i<442 do
prepare s1 from @stmt;
execute s1 using @b,@i,@c;
deallocate prepare s1;
set @i=@i+1,@b=@b+1,@c=@c+1;
end while;
end
begin
declare i int;
declare b int;
declare c int;
set @i=2;
set @b=6;
set @c=0;
set @stmt = concat('insert into t_j_goods_name (id,`code`,`name`)
values(?,?,(select distinct `a` from sheet1 limit ?, 1))');
while @i<442 do
prepare s1 from @stmt;
execute s1 using @b,@i,@c;
deallocate prepare s1;
set @i=@i+1,@b=@b+1,@c=@c+1;
end while;
end
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询