Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Command Query Question

Author  Topic 

aee156
Starting Member

2 Posts

Posted - 2011-09-01 : 01:58:17
Hello,

I am new to SQl and I have an e-commerce store. I want to take all my product prices and change the to 10% lower then what they are right now.

I know how to change them and to raise the price 20% with this code

UPDATE ps_product SET price = price * 1.20

However I dont know how to minus the amount. What would that code be to take off 10% instead of add 20%?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-01 : 02:11:51
[code]UPDATE ps_product SET price = price * 0.9[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

aee156
Starting Member

2 Posts

Posted - 2011-09-01 : 02:32:38
Thanks!!!

That worked perfectly.

Here is another one, I have suppliers for all the products in my store, I want to take just the supplier of A only (for instance) and change all the prices up 30% but only for the WHERE supplier equals A.

Any idea on this code, based on the code I just used? Basically what code could I add to create that where clause?

Thanks again for all your help!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-01 : 02:37:06
[code]UPDATE ps_product SET price = price * 1.3
WHERE supplier = 'A'
[/code]

read about UPDATE statement on below link and you'll understand how it works

http://msdn.microsoft.com/en-us/library/ms177523(v=SQL.100).aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -