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 中使用它
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 中使用它
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;