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?
This can be done using the SQL Update statement :
Update statement
UPDATE products SET price = price * 1.2 WHERE type = 'Imported'
This will increase the price all imported products by 20%.
price
imported
products
This should do the trick:
UPDATE products SET price = (price * 1.2) WHERE type = 'imported'
Source: https://habr.com/ru/post/1303880/More articles:Need help understanding "TypeError: by default, __new__ does not accept any parameters" error in python - pythonjQuery: marginal animation works in Chrome, not Firefox and IE - jqueryChanging the value of an ActiveRecord attribute in a before_save element - ruby | fooobar.comC # Wrap and Callbacks - c #Design for teaching the art of artificial intelligence - designGenerating an SQL query that selects the maximum difference between the two fields - sqlcalling a C ++ function using a reference parameter from cli - pass-by-referenceProblem launching a RoR application in a production environment - ruby-on-railsUnexpected result printf - cHow to use DML for an Oracle temporary table without generating a large number of undo logs - oracleAll Articles