2012-11-15 77 views

回答

1

空不能被用於測試記錄(在)平等聲明。你需要使用IS NULL。例如

select * 
from person 
where (type != 'admin') or (type IS NULL) 

例如,空是「傳染」

null > x -> null 
null = x -> null 
null = null -> null 
null + 1 -> null 
null * 1 -> null 

等......它基本上是「未知的」。在SQL中混合已知和未知的結果始終是未知的。因此,特殊的ifnull(),coalesce()和「if null」測試/函數。

+0

由於使用NULL safe equality operator!兩個答案似乎都足夠。然而,將NULL安全運算符放入我使用的框架中會比OR更有一點三分 – cgmckeever

0

你可以在MySQL

select * 
from person 
where not type <=> 'admin'