Need help with sql update request

I have tabular “products” and I need to update the “price” field by 20% if the product type field is “imported”.
How can I read and update a field at the same time in my UPDATE query?

+4
source share
2 answers

This can be done using the SQL Update statement :

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

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

+6
source

This should do the trick:

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

+4
source

Source: https://habr.com/ru/post/1303880/


All Articles