netpants Posted February 7, 2007 Share Posted February 7, 2007 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/37401-update-query-help-needed/ Share on other sites More sharing options...
genericnumber1 Posted February 7, 2007 Share Posted February 7, 2007 Not sure why it's doing that but you could simplify the math, though it's very doubtful that it would fix your problem... $db->query("UPDATE users SET uOffensiveMen = uOffensiveMen * 0.9 WHERE uRace=1 AND uOffensiveMen > 10"); I've never done anything with math in sql so I'm not sure why it would do that, sorry. This might be better suited in the MySQL forum though Link to comment https://forums.phpfreaks.com/topic/37401-update-query-help-needed/#findComment-178791 Share on other sites More sharing options...
netpants Posted February 7, 2007 Author Share Posted February 7, 2007 Ok ill post in there. Link to comment https://forums.phpfreaks.com/topic/37401-update-query-help-needed/#findComment-178800 Share on other sites More sharing options...
netpants Posted February 7, 2007 Author Share Posted February 7, 2007 By the way I tried that before and It for some reason increased the value instead of decreasing it. Link to comment https://forums.phpfreaks.com/topic/37401-update-query-help-needed/#findComment-178803 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.