写sql脚本实现,然后执行该脚本。
如test.sql 脚本编写如下:
insert into B [(字段1,字段2,...)] select * from A where 条件=‘条件’;
delete from A where 条件=‘条件’;
|
insert into user3 (username,age) select username,age from user2; 主键会从1(或原有的)开始
mysql> insert into user3 (username,age) select username,age from user2 where `username` = '小红';
然后执行该test.sql脚本
mysql -u test -p123456 <test.sql