I tried the following to decrease a counter after a post was deleted by using
GREATEST() so it does not result a negative value:
SELECT GREATEST(0, posts - 1) FROM users WHERE id = 123
but it returns:
[Err] 1690 - BIGINT UNSIGNED value is out of range in '(`db1`.`users`.`posts` - 1)'
SELECT posts FROM users WHERE id = 123
An the following returns
0 as expected:
SELECT GREATEST(0, 0 - 1)
So what I'm doing wrong?