我的数据库中有从 0 开始的数据。
我的 php 会根据用户的输入将 1 或 -1 添加到数据中。 我的问题是,如果数据为 0 并且用户尝试减去 1。数据变为 4294967295 这是 INT 数据类型的最大值。反正有没有制作数据 即使用户要求 -1 也保持为 0?感谢您的回复..
我的sql命令如下
update board set score=score-1 where team='TeamA'
//this would generate 4294967295 if the score is 0.....
最佳答案
是的..
UPDATE board SET score = score - 1 WHERE team = 'TeamA' AND score > 0
关于php - Mysql中如何防止负数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2951136/