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/37401-update-query-help-needed/
Share on other sites

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

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.