How to prevent negative number in Mysql
Posted
by Jerry
on Stack Overflow
See other posts from Stack Overflow
or by Jerry
Published on 2010-06-01T15:40:39Z
Indexed on
2010/06/01
15:43 UTC
Read the original article
Hit count: 157
Hello guys.. I have data which is starting from 0 in my database.
My php will add 1 or -1 to the data depending on the user's input. My problem is that if data is 0 and a user try to subtract 1. The data become 4294967295 which is the maximum value of INT data type. Are there anyways to make the data stays in 0 even when the user asks for -1? Thanks for the reply..
my sql command is like below
update board set score=score-1 where team='TeamA'
//this would generate 4294967295 if the score is 0.....
© Stack Overflow or respective owner