Vâng, đối với cả hai so sánh và cập nhật, 0 và 1 công việc cho tôi:
Dưới đây là một lĩnh vực loại bit (1), một hàng, lĩnh vực này là hiện sai:
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)
cập nhật thay đổi 0-1 trong isfeatured, đó là loại bit (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
Một hàng thay đổi ... Hãy thử nó một lần nữa:
mysql> update nodes set isfeatured=1 where isfeatured = 0;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
Không có hàng thay đổi như mong đợi.
chọn truy vấn tương tự như trước đây:
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)
Xem, nó hoạt động.
Tôi đang sử dụng:
mysql Ver 14,14 distrib 5.5.31, cho debian-linux-gnu (x86_64) sử dụng readline 6.2
và
/usr/sbin/mysqld Ver 5.5.31-0 + wheezy1 cho debian-linux-gnu trên x86_64 ((Debian))
Nguồn
2013-09-07 11:27:48
câu trả lời của bạn là đúng. Tôi không biết ký hiệu này. – Luixv