开发者

Need help with sql update query

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜