xwishmasterx Posted April 3, 2011 Share Posted April 3, 2011 hi Lets say a member has 4500 points and I have this code: UPDATE points SET members_point=(members_point+1000)....... but will not allow it to go above 5000 how should this be written? Quote Link to comment https://forums.phpfreaks.com/topic/232588-update-table-but-maintain-a-maximum-value/ Share on other sites More sharing options...
Zurev Posted April 3, 2011 Share Posted April 3, 2011 You could always check if the updated value is going to be over 5,000 and if so set it to 5,000. I'm unsure of the more efficient way to do it in SQL, so the above suggestion would most likely be a short term fix. Quote Link to comment https://forums.phpfreaks.com/topic/232588-update-table-but-maintain-a-maximum-value/#findComment-1196348 Share on other sites More sharing options...
sasa Posted April 4, 2011 Share Posted April 4, 2011 UPDATE points SET members_point=IF(members_point+1000 > 5000, 5000, members_point+1000)....... Quote Link to comment https://forums.phpfreaks.com/topic/232588-update-table-but-maintain-a-maximum-value/#findComment-1196458 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.