insert into A select * from B
insert into A select * from C
insert into A select * from D
2、删除重复的记录只保留一行
delete from A where name in (select id from t1 group by id having count(id) >1)and rowid not in (select min(rowid) from t1 group by id having
count(*)>1)
3、记录一下这些重复的记录,
mysql -uroot -p123456 -Ddb01 -e 'select b.id from t1 b group by id having count(b.id) >1' | tail -n +2 >repeat.txt
删除全部重复的记录
delete from A where name in (select name from t1 group by name having count(name) >1)
再次插入多删的重复记录
#!/bin/sh
for id1 in `cat repeat.txt`do
mysql -uroot -p123456 -Ddb01 -e "insert into A select * from B where id='${id1}'"
done
给你几个情况1.如果是累加name是这样的
update
b
set
name=name+a.name
from
a
where
a.url=b.http
2.直接插入
insert
b(name)
select
name
from
a
join
b
on
a.url=b.http
3.替换原来的name
update
b
set
name=a.name
from
a
where
a.url=b.http
insert into table1 values(数据)insert into table2 values(数据)
insert into table3 values(数据)
一起提交就是多个表同时添加
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)