tags:

views:

32

answers:

2

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?

+6  A: 

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%.

codaddict
+4  A: 

This should do the trick:

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

Mike Cialowicz