表A有字段 id(identity1,1) 序列号 数量 种类 类型等表B有字段 id(identity1,1) 序列号 型号 数量 种类 来源 等表A中的数据有一部分在表B中也有,还有一部分表B中没有需要从表A中导过来(主要导的是序列号,数量,种类,型号默认为1)
但是表A中的序列号有重复的但其他字段没有重复信息,如何根据类型把这些重复的数据查出来也导入到表B中
但是表A中的序列号有重复的但其他字段没有重复信息,如何根据类型把这些重复的数据查出来也导入到表B中
查底重复的数据再导入表B中
重复数据查询见贴:
http://http://topic.csdn.net/u/20100511/08/69f1091b-7d6f-4ca6-b1bc-cd557c3ef38a.html?73674
select collist from a where not exists(select 1 from b where b.序列号=a.序列号)?
insert into 表B (序列号 ,数量 ,种类, 型号)
select 序列号 ,数量 ,种类, 型号 from 表A
where exists(select 1 from 表A t where t.序列号=序列号 and (t.种类<>种类 or t.数量<>数量 or t.类型<>类型))insert into 表B (序列号 ,数量 ,种类, 型号)
select 序列号 ,数量 ,种类, 型号 from 表A
where exists(select 1 from 表A t where t.序列号=序列号 and (t.种类<>种类 and t.数量<>数量 and t.类型<>类型))