Marny Lopez
Marny Lopez

Reputation: 159

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..

Upvotes: 0

Views: 53

Answers (1)

Pரதீப்
Pரதீப்

Reputation: 93694

Use Update from JOIN syntax

update Transactions A
INNER JOIN Products B
ON A.IdProd = B.IdProd
set A.Total = A.Quantity * B.cost

Upvotes: 1

Related Questions