SQL UPDATE多表关联

文章转自: https://www.cnblogs.com/panshare/p/8520764.html

1、SqlServer

UPDATE a SET a.a1=b.b1,a.a2=b.b2 FROM A a INNER JOIN B b ON a.a3=b.b3

2、Oracle

UPDATE A a  SET (a.a1,a.a2)=(SELECT b.b1,b,b2 FROM B b WHERE b.b3=a.a3)
个人例句:
update fsp_cms.cms_sm_contract cs set cs.supermarket_name =(select vm."KAMC" from VW_CRMKAHT@cwbaselh90 vm where  cs.serial_number=vm."LSBH"  )
where cs.supermarket_name is null;

3、MySql

UPDATE A a , B b SET a.a1 = b.b1 , a.a2 = b.b2 WHERE a.a3 = b.b3

posted @ 2019-09-26 16:53  疯狂电脑  阅读(151)  评论(0编辑  收藏  举报