日期:2014-05-18  浏览次数:20495 次

2个表合并问题,大家帮我看下吧
A表,id     msmc     msdm     zt
B表,id     msmc     msdm     zt

把A合到B,     但只合msdm不相同的记录

------解决方案--------------------
insert into B select * from A where not exists(select 1 from B where msdm=A.msdm)
------解决方案--------------------
insert into B
select * from A where not exists(select 1 from B where msdm=A.msdm)
------解决方案--------------------
select * from A as tmp
where exists(select 1 from B where msdm <> tmp.msdm)
union all
select * from B