2

i want to subtract 1 from a variable who is stored in my table in mysql

i do it by this query

UPDATE table SET  var = var -1

but when i do it

0 - 1 = -1

but mysql do

0 - 1 = 9223372036854775807 when i set in bigint when i set it to int property then he do

0 -1 = 2147483647

what i do to get

0 - 1 = -1
Paul
  • 19,704
  • 14
  • 78
  • 96

1 Answers1

1

You need to choose a different (signed) data type that allows storing negative values.

look here for some background :

Community
  • 1
  • 1
lexu
  • 8,766
  • 5
  • 45
  • 63