Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help with sql update query

Tags:

sql

oracle10g

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?

like image 871
via_point Avatar asked Dec 28 '22 23:12

via_point


1 Answers

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

like image 198
codaddict Avatar answered Jan 18 '23 01:01

codaddict