I have a table with a column
unsigned int, let's name it col1.
I want to decrement the column by a number, if value after decrement is less than 1 then set it to 1. Like this:
UPDATE `tbl1` SET `col1` = GREATEST(1, `col1`-3);
This works fine, but if col1 is 0 or 1 or 2 and I try to do -3 then MySQL throws an error.