如何快速地将两个相同的SQL表合并在一起?
如何快速地将两个相同的SQL表合并在一起?
日期:2016-09-23 12:27:40 人气:1
解决方案如下:
--先更新
update tab1 set tab1.count = tab1.count + t2.count
from tab2
where tab1.id = tabl2.id
--再插入
insert into tab1(id,count)
select id,count from tab2
where id not in (select id from tab1)