1

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)

3 Answers 3

1

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;
Sign up to request clarification or add additional context in comments.

Comments

0

Change action = null to action is null.

Comments

0

try with IS NULL:

select id 
from notifications 
where user_id = 1 
and action IS NULL

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.