开发者

Need help with sql update query

开发者 https://www.devze.com 2022-12-22 13:25 出处:网络
I have table \'products\' and I need to update \'pri开发者_运维问答ce\' field by 20% if product \'type\' field is \"imported\".

I have table 'products' and I need to update 'pri开发者_运维问答ce' field by 20% if product 'type' field is "imported".

How do I read and update field at the same time in my UPDATE query?


You can do that using the SQL's Update statement:

UPDATE products 
SET price = price * 1.2
WHERE type = 'Imported'

This will increase the price of all imported products by 20%.


This should do the trick:

UPDATE products SET price = (price * 1.2) WHERE type = 'imported'

0

精彩评论

暂无评论...
验证码 换一张
取 消