sql 一个多表连接的更新语句

sql 一个多表连接的更新语句,第1张

update A,B,C set A.ls=C.ls where A.bmid=B.bmid and B.dj=C.dj

或者:

update A as a,B as b,C as c set a.ls=c.ls where a.bmid=b.bmid and b.dj=c.dj

update A set A. nature='XXX' from A, B, C where A.id=B.rowid and B.rowid=C.kid and (这里写你的条件, 比如什么哪个表的ID)

可以这样更新

update Product SET 库存= T1.数量 - T2.数量

from

(select 商品名称,sum(数量) as 数量 from purchase group by 商品名称) as T1,

(select 商品名称,sum(数量) as 数量 from sale group by 商品名称) as T2

where T1.商品名称 = T2.商品名称 and product.商品名称 = T1.商品名称


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/10648486.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-10
下一篇2023-05-10

发表评论

登录后才能评论

评论列表(0条)

    保存