Jump to content

UPDATE query - Help Needed


netpants

Recommended Posts

OK I am trying to subtract 10% from the value of the uOffensiveMen Table if the value is greater than 10.

 

$db->query("UPDATE users SET uOffensiveMen=uOffensiveMen-(uOffensiveMen*0.10) WHERE uRace=1 AND uOffensiveMen>10");

 

I start with the value of 20 in my table and it subtracts 2 the first time, but then when I run it again it still subtracts 2, and run again it will only subtract 2 again over and over until the value is below 10.

 

What am I doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/37407-update-query-help-needed/
Share on other sites

Can you run the query manually to verify that it is in fact subtracting 2 every time?  You could try this out:

 

SELECT uOffensiveMen, uOffensiveMen*0.10 AS sub FROM users WHERE uRace=1 AND uOffensiveMen>10

 

And yes, I am interested in the other queries that surround that query :)  The entire script if possible, as long as it's not hundreds or thousands of lines.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.