Reputation: 3226
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)
Upvotes: 1
Views: 38
Reputation: 1819
try with IS NULL
:
select id
from notifications
where user_id = 1
and action IS NULL
Upvotes: 0
Reputation: 6461
NULL
cannot be equal to anything, including itself. You should use is
with it..
select id from notifications where user_id = 1 and action is NULL;
Upvotes: 1