I have this query
UPDATE table SET this = this-20 WHERE this >= 0
i dont want this field to ever go under 0. Is there some addition I can add to this query to ensure this, without having to run another query?
eg, if this was 18, then it would be set to -2
(USING MYSQL)
You can make use of the Greatest function:
that basically set the value of this with the bigger value considering this – 20 and 0.