sql 从一张表中查一个字段更新另一张表中的一个对应字段

时间:2021-06-07 00:30:39

 

更新一列数据

update CustomerPromoteDetail set QuantityTotal=QuantityTotal-temp.Quantity
from (select idPromote,Quantity from SODetailPre where bCX = 1 and id =16658) as temp
where AutoID = temp.idPromote

update CustomerPromoteDetail set QuantityTotal=(QuantityTotal-
(select Quantity from SODetailPre where bCX = 1 and id =16658 and CustomerPromoteDetail.AutoID = SODetailPre.idPromote))