insert into user
(account_id, name, e_mail_addr)
select account_id, name, e_mail_addr
from user
where account_id='1';
如何复制id = id +1的行并循环100次。这意味着它将创建100行,id为2到100。 我在phpmyadmin中使用它
答案 0 :(得分:0)
SQL过程:
drop procedure if exists user_clone;
delimiter #
create procedure user_clone()
begin
declare u_max int unsigned default 100;
declare u_counter int unsigned default 0;
start transaction;
while u_counter < u_max do
INSERT INTO (name, e_mail_addr)
SELECT name, e_mail_addr
FROM user
WHERE account_id = 1;
set u_counter=u_counter+1;
end while;
commit;
end #
delimiter ;
call user_clone();
drop procedure user_clone;