2015-10-10 108 views
1

我知道這是一個非常簡單的問題,但爲什麼不是我的查詢返回任何東西?多在哪裏在MySQL查詢不返回任何東西

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) 

回答

0

action = null更改爲action is null

0

嘗試IS NULL

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

NULL不能等於任何東西,包括自己。你應該使用它is ..

select id from notifications where user_id = 1 and action is NULL;