mysql - sql boolean truth test: zero OR null -


is there way test both 0 , null 1 equality operator?

i realize this:

where field = 0 or field null

but life hundred times easier if work:

where field in (0, null)

(btw, why doesn't work?)

i've read converting null 0 in select statement (with coalesce). framework i'm using make unpleasant.

realize oddly specific, there way test 0 , null 1 predicate?

it not work because field in(0,null) equivalent of field = 0 or field = null opposed field = 0 or field null. 1 option use case expression:

case  when field = 0 1  when field null 1 end = 1 

the better option stick original field = 0 or field null makes intent clearer.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -