Jump to content

update values in mysql by percentage


Merdok

Recommended Posts

OK I'm sure this is a very easy question but I am terrible with mathematics and I can't get my head around this one.

 

I have an ecommerce store and I want to increase all the prices on the site by 6%, is this the correct way to do it?

 

UPDATE shop_prod SET price = price * 0.6

 

I'm sure the maths is wrong there and that is where I'm falling down I expect.

Link to comment
Share on other sites

Hmm... I tried this but it didn't seem to work properly

 

 

UPDATE shop_prod SET price = price * .06

 

the prices ended up being reduced instead, for example a product that was £407 became around £24

 

What did I do wrong?

 

Link to comment
Share on other sites

Hmm... I tried this but it didn't seem to work properly

 

 

UPDATE shop_prod SET price = price * .06

 

the prices ended up being reduced instead, for example a product that was £407 became around £24

 

What did I do wrong?

 

 

Sorry, that would set the prices to 6% of their original value.  This should be what you want:

 

UPDATE shop_prod SET price = price + (price*.06)

Link to comment
Share on other sites

If you need help restoring prices then marking them up:

 

price / 0.06 * 1.06

 

price / 0.06 restores the orig * 0.06 error

 

*1.06 does the 6 percent markup

 

By the way, using order of operations on the above post, you get (price * .12) since multiplication comes first.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.