advo Posted March 5, 2011 Share Posted March 5, 2011 hi i have been having a issue that for life of me just isnt sitting in my head right i have a table called `ranks` with a persons `userID` and various ranks inside it like income whatnotthis table holds there main rank under field `rank` there userinformation is help in `userdeatials` i added a fields called `glorypoints` now what im trying to do is if say there rank is below between 1- 10 give them 2 glory points if 11-50 give them 1 and those above that get nothing now this is what i have and it dose not update the proper parts of table ie rank 1-50 every one is getting them this is the code im using\ UPDATE userdetails SET glorypoints = glorypoints+'2' WHERE rank > 11 AND rank < 50 AND ranks.userID=userdeatils.ID Link to comment https://forums.phpfreaks.com/topic/229680-some-help-please/ Share on other sites More sharing options...
fenway Posted March 6, 2011 Share Posted March 6, 2011 This best handed with CASE. Link to comment https://forums.phpfreaks.com/topic/229680-some-help-please/#findComment-1183552 Share on other sites More sharing options...
advo Posted March 6, 2011 Author Share Posted March 6, 2011 what do you mean CASE please explain am i doing it right or wrong some one help please Link to comment https://forums.phpfreaks.com/topic/229680-some-help-please/#findComment-1183562 Share on other sites More sharing options...
Simmo Posted March 6, 2011 Share Posted March 6, 2011 you are refering to a table rank "AND ranks.userID=userdeatils.ID" but you have not have joined it so off the top of my head: UPDATE userdetails Inner Join rank On rank.userID = userdeatils.ID SET glorypoints = glorypoints+'2' WHERE rank > 11 AND rank < 50 AND ranks.userID=userdeatils.ID Link to comment https://forums.phpfreaks.com/topic/229680-some-help-please/#findComment-1183568 Share on other sites More sharing options...
fenway Posted March 7, 2011 Share Posted March 7, 2011 what do you mean CASE please explain am i doing it right or wrong some one help please CASE WHEN rank > 11 AND rank < 50 THEN glorypoints = glorypoints + 1 WHEN rank > 0 AND rank < 12 THEN glorypoints = glorypoints + 2 END CASE ...etc. Link to comment https://forums.phpfreaks.com/topic/229680-some-help-please/#findComment-1184030 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.