Without using PHP or anything. Is there a way to do something like this:
UPDATE myTable SET var1 = var1 + 1 IF var1 < 5 ELSE var1 = 0 WHERE [WHERE clause]
Never really done any IF mySQL things so a little unsure?
So the result would be that the variable would never be higher than 5 and reset to 0 if its at 5 when incremented.
TIA
Either use IF()
or in this case, simpler, just use the modulo operator
Edit: Yes, I realize that if the range starts outside of 0..5 the latter one will not work, I just figured the intent was to keep the numbers between 0 and 5 inclusive. If I’m wrong about that, keep to the first one 🙂