Reputation: 2723
I have table 'products' and I need to update 'price' field by 20% if product 'type' field is "imported".
How do I read and update field at the same time in my UPDATE query?
Upvotes: 4
Views: 119
Reputation: 10020
This should do the trick:
UPDATE products SET price = (price * 1.2) WHERE type = 'imported'
Upvotes: 4
Reputation: 454960
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%.
Upvotes: 6