via_point
via_point

Reputation: 2723

Need help with sql update query

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

Answers (2)

Mike Cialowicz
Mike Cialowicz

Reputation: 10020

This should do the trick:

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

Upvotes: 4

codaddict
codaddict

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

Related Questions