UPDATE posts set votes=votes+1 where id='$id'
The above works when the value is zero, but when i Subtract (current value of 0):
UPDATE posts set votes=votes-1 where id='$id'
It's having an error. Why is that so?
datatype is int
UPDATE posts set votes=votes+1 where id='$id'
The above works when the value is zero, but when i Subtract (current value of 0):
UPDATE posts set votes=votes-1 where id='$id'
It's having an error. Why is that so?
datatype is int
Make the votes column signed (so untick the unsigned checkbox).
Unsigned integer columns (which is default in most tools) can only contain positive integers. Signed integers have an extra bit for the - (so they support negative values).