你可以試試這個:deleted_1 is not null and deleted_1 != '1'
?
mysql> select 0 is not null and 0 != '1', 1 is not null and 1 != '1', null is not null and null != '1';
+----------------------------+----------------------------+----------------------------------+
| 0 is not null and 0 != '1' | 1 is not null and 1 != '1' | null is not null and null != '1' |
+----------------------------+----------------------------+----------------------------------+
| 1 | 0 | 0 |
+----------------------------+----------------------------+----------------------------------+
還是這個deleted_1 is null or deleted_1 != '1'
:
mysql> select 0 is null or 0 != '1', 1 is null or 1 != '1', null is null or null != '1';
+-----------------------+-----------------------+-----------------------------+
| 0 is null or 0 != '1' | 1 is null or 1 != '1' | null is null or null != '1' |
+-----------------------+-----------------------+-----------------------------+
| 1 | 0 | 1 |
+-----------------------+-----------------------+-----------------------------+
這真的取決於你想要什麼回來。
爲什麼1被封閉在像繩子報價工作? –
'WHERE \'deleted_1 \'!='NULL''你不應該這樣做。 NULL是特別的,看看我的答案。 – TimWolla
@TimWolla謝謝你,我會按你的方式去做。 – Linas