您的值很可能ended
是 SQLNULL
值。空值的逻辑not
仍然为空,因此数据库正确报告“没有更改”,因为中的值ended
没有改变 - 它开始为空,并且仍然为空:
mysql> create table foo (x boolean);
mysql> insert into foo values (null);
Query OK, 1 row affected (0.04 sec)
mysql> update foo set x=not x;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> update foo set x=not x;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
注意Changed: 0
. 但是,一旦您将 x 重置为非空值:
mysql> update foo set x=true;
Query OK, 1 row affected (0.06 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update foo set x=not x;
Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0
行立即开始更改。