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