php - limit column in database with UPDATE -


i have turns col. updated every half hour , add 5 turns every user on website.

i want make limit, example 300, , every user has 295 or more updated 300, no more or less.

this query right now:

update `user_d` set turns=turns+5 id='".$id."' 

if i'll add "where turns < 300" users has 298 example jump 303 (over limit), how can limited 300?

thx! english isn't strong , tryied make understandable, please ask me try , explain better if don't understood meant.

use sql case, turns below 296 limit 300

 update        `user_d`     set         turns         (             case                 when                     ((turns) < 296)                                    turns=turns+5                 else                     (turns)             end         )            id='".$id."' 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -