私はいくつかのMySQLコードを持っています:
CREATE TABLE test_table (
id int(11) NOT NULL AUTO_INCREMENT,
count int(10) unsigned DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
insert into test_table (count) values (1);
update test_table set count = IF( count -1 < 0, 0 , count -1 );
update test_table set count = IF( count -1 < 0, 0 , count -1 );
の場合、これはカウントをゼロに設定する必要があります(count -1) < 0
。
エラーが発生します:
Error Code: 1264 Out of range value for column 'count' at row 1` instead.
これは、count が unsigned int であるためです。signed int を使用すると機能します。
これは MySQL のバグですか? 私は使用しています: mysql Ver 14.14 Distrib 5.1.46sp1, for Win32 (ia32)