update table1 set table1.列=table2.列 from table2 where table2.列=table1.列
update NFYSP.dbo.PATIENT set
PATIENT_ADDUSERID=OLD.PATIENT_ADDUSERID
,PATIENT_UPDATEUSERID=OLD.PATIENT_UPDATEUSERID
,PATIENT_UPDATEUSERNAME=OLD.PATIENT_UPDATEUSERNAME
,PATIENT_ADDUSERNAME=OLD.PATIENT_ADDUSERNAME
from CRM_XJP.dbo.PATIENT OLD where PATIENT.id=OLD.id
UPDATE ASET foo = B.barFROM
TableA A
JOIN TableB B
ON A.col1 = B.colx
WHERE ...
参考:http://stackoverflow.com/questions/982919/sql-update-query-using-joins Sql从一张表中更改另一张表数据,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/huangtailang/p/8057837a84d6656be17492c6cd08fb07.html