Nun, für beide Vergleiche und Updates, 0 und 1 für mich arbeiten:
Hier ist ein Feld vom Typ Bit (1), ein Reihe, ist das Feld derzeit false:
mysql> select isfeatured from nodes where isfeatured = 1;
Empty set (0.00 sec)
mysql> select isfeatured from nodes where isfeatured = 0;
+------------+
| isfeatured |
+------------+
| |
+------------+
1 row in set (0.00 sec)
aktualisieren Ändern 0 auf 1 in isfeatured, die Typ-Bit ist (1) ...
mysql> update nodes set isfeatured=1 where isfeatured = 0;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Eine Zeile geändert ... Versuchen Sie es erneut:
mysql> update nodes set isfeatured=1 where isfeatured = 0;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
keine Zeilen wie erwartet geändert.
Gleiche Auswahlabfragen wie zuvor:
mysql> select isfeatured from nodes where isfeatured = 1;
+------------+
| isfeatured |
+------------+
| |
+------------+
1 row in set (0.00 sec)
mysql> select isfeatured from nodes where isfeatured = 0;
Empty set (0.01 sec)
See, es funktioniert.
Ich verwende:
mysql Ver 14.14 Distrib 5.5.31, für debian-linux-gnu (x86_64) mit Readline- 6.2
und
/usr/sbin/mysqld Ver 5.5.31-0 + wheezy1 für debian-linux-gnu auf x86_64 ((Debian))
Ihre Antwort richtig ist. Ich kannte diese Notation nicht. – Luixv