[英]MySQL update a field using info in other table
How can I make an update of this tables?: 如何更新这些表?:
Products table 产品表
Transactions table 交易表
I want to update the Total quantity finding the Cost in the products table, and multiplying it to my Quantity in my transactions table, but I don't really know how can I do this.. 我想更新在产品表中找到成本的总数量,并将其乘以我的交易表中的数量,但我真的不知道我该怎么做...
Use Update
from JOIN
syntax 使用JOIN
语法Update
update Transactions A
INNER JOIN Products B
ON A.IdProd = B.IdProd
set A.Total = A.Quantity * B.cost
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.