sql 中怎么将A表插入B表中,,去除两张 表中含有的重复数据

insert into B(字段列表) select 字段列表 from A  where not exists(select * from B where a.keycol1 = b.keycol1)

keycol1为A表和B 表中的字段,可能带有主键,可以此字段来判断A表和B表中是否存在相同的数据,where not exists是作为一个条件来判别从A表往B表中插入的数据不与B表已存在的数据重复

猜你喜欢

转载自blog.csdn.net/yiyihuazi/article/details/82932762
今日推荐