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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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).