How to do subtraction in mysql

I want to subtract 1 from a variable that is stored in my table in mysql

I am doing it for this request

UPDATE table SET  var = var -1

      

but when i do it

0 - 1 = -1

      

but mysql do

0 - 1 = 9223372036854775807

when i set to bigint when i set it to int property then it does

0 -1 = 2147483647

      

what i do to get

0 - 1 = -1

      

+2


a source to share


1 answer


You need to choose another (signed) data type that allows negative values ​​to be stored.

Look at some background here:



+1


a source







All Articles