1.insert into table1
select * from table2 where col1+col2+...+coln
not in (select col1+col2+...+coln from table1)
2. if exists (select * from table2 where col1+col2+...+coln
not in (select col1+col2+...+coln from table1)
)
insert into table1
select * from table2 where col1+col2+...+coln
not in (select col1+col2+...+coln from table1)
else
update table1 set col1=t2.col1 and col2=t2.col2 ...
from table1 t1 ,table2 t2 where t1.col1=t2.col1注意,1和2 的语句中,col1+col2+...+coln 各列必须是同一类型。如不是,则强行转变为同一类型,最好是字符型。
select * from table2 where col1+col2+...+coln
not in (select col1+col2+...+coln from table1)
2. if exists (select * from table2 where col1+col2+...+coln
not in (select col1+col2+...+coln from table1)
)
insert into table1
select * from table2 where col1+col2+...+coln
not in (select col1+col2+...+coln from table1)
else
update table1 set col1=t2.col1 and col2=t2.col2 ...
from table1 t1 ,table2 t2 where t1.col1=t2.col1注意,1和2 的语句中,col1+col2+...+coln 各列必须是同一类型。如不是,则强行转变为同一类型,最好是字符型。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货