The question below comes from this site. It's an accepted answer. However, this syntax doesn't work for me. I get an error on the comma (after carts c,) that I'm missing the SET keyword. 1) Is the syntax below incorrect, and 2) if it is incorrect, then how can you update multiple rows using data from other columns, the way it's described below?
<<
the above update is incorrect :
UPDATE carts SET carts.format_code = prices.format_code
WHERE cart_item_id IN
(SELECT cart_item_id from prices, carts
WHERE blah blah blah.....)
the 'prices' table is unknown to the update statement, and only exists in the sub-select.
However, you can issue the following update commnad in order to get the requested affect :
UPDATE carts c, prices p
SET c.format_code = p.format_code
WHERE c.cart_item_id IN
(SELECT t.cart_item_id from prices r, carts t
WHERE r.<price_table_key> = p.<price_table_key>
AND blah blah blah.....)
Hope it answered your question.
>>
Start Free Trial