update tb2 set cid = tb1.pid from tb1 where tb1.cid = tb2.cid
update tb2 set pid=b.pid from tb2 a,tb1 b where a.cid=b.cid
update tb2 set pid=tb1.pid from tb1 ,tb2 where tb1.cid=tb2.cidgo insert tb2(cid,pid) select cid,pid from tb1 where not exists(select 1 from tb2 where cid=tb1.cid )
--一段為存在更新tb2.pid --二段為不存時新增到tb2
select tb1.pid from tb1,tb2 where tb1.cid=tb2.cid 查出来的是一列啊 要赋值过去 最好要有循环就好呢
set cid = tb1.pid
from tb1
where tb1.cid = tb2.cid
set pid=tb1.pid
from tb1 ,tb2
where tb1.cid=tb2.cidgo
insert tb2(cid,pid)
select cid,pid
from tb1
where not exists(select 1 from tb2 where cid=tb1.cid )
--二段為不存時新增到tb2