Reputation: 3254
There are 2 connected tables
uc_products
with fieldsvid
sell_price
uc_product_options
with fieldsnid
oid
price
and vid == nid
I need to get all prices
from uc_product_options
and add them to uc_products
in sell_price
column.
I know how to select all values I need
SELECT nid, oid, price FROM uc_product_options WHERE oid = 3;
but how to combine this query with UPDATE
query for the second table?
Upvotes: 0
Views: 42
Reputation: 69440
Update
... join
should help you:
UPDATE uc_products a
JOIN uc_product_options b ON a.nid = b.vid
SET a.sell_price = b.price
where b.oid=3
Upvotes: 1
Reputation: 133360
Update the joined tables
update uc_products
join uc_product_options on uc_products.vid = uc_product_options.nid
set uc_products.sell_price_ = uc_product_options.price
where uc_product_options.oid = 3
Upvotes: 1