MySQL: Update Value from Another table

Sometimes we need to update value from value of another table.
For detail explanation I'll show you and example.
We have 2 tables named `product` and `purchase`:
Table: product:
Table:puchase:

We will update price field value of product table using purchase value on purchase table.

SQL Update:
UPDATE product p
INNER JOIN purchase pp
ON p.itemcode = pp.itemcode
SET p.price = pp.purcaseprice * 1.5

Result:


Click here if you like this article.


Post a Comment

0 Comments