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
Post a Comment