[英]Multiple where in mysql query not returning anything
I know that this is a very easy question, but why isn't my query returning anything ? 我知道这是一个非常简单的问题,但是为什么我的查询不返回任何内容?
mysql> select * from notifications;
+----+---------+-------------+---------+--------+---------------------+
| id | user_id | sec_user_id | item_id | action | date |
+----+---------+-------------+---------+--------+---------------------+
| 1 | 1 | NULL | NULL | NULL | 2015-10-09 23:47:36 |
+----+---------+-------------+---------+--------+---------------------+
1 row in set (0.00 sec)
mysql> select id from notifications where user_id = 1 and action = NULL;
Empty set (0.00 sec)
NULL
cannot be equal to anything, including itself. NULL
不能等于任何东西,包括它本身。 You should use is
with it.. 您应该使用is
有它..
select id from notifications where user_id = 1 and action is NULL;
将action = null
更改为action is null
。
try with IS NULL
: 尝试使用IS NULL
:
select id
from notifications
where user_id = 1
and action IS NULL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.