Reputation: 317
I am trying to write a little bit of code to update the prices in my database which I have set before in an Excel sheet.
For this I need to update 1 of two columns. In case the column "override" is 1 I need to update the column product_override_price otherwise I need to update product_price.
For doing this I wrote the following test code however it tells me I have an error which I can't find.
UPDATE `product_prices`
case when `override` ='1' then SET `product_override_price`= '100' else SET `product_price`= '100' end where `product_id`='6'
I would appreciate any help in this. Please note the code needs to be reproduced for 50 other product_id's.
Upvotes: 1
Views: 31
Reputation: 204766
UPDATE `product_prices`
SET `product_override_price` = case when `override` ='1'
then '100'
else product_override_price
end,
`product_price`= case when `override` <> '1'
then '100'
else product_price
end
where `product_id`='6'
Upvotes: 3