Reputation:
In one of my MySQL table column fields may have NULL
, 0
, empty or space character value, also 1, 2, 45, etc..
I need just easier way for filtering positive integer values against empty ones.
I know I can use simply field <= 0
when I need empty values but null
values are excluded, simply I'd add or field IS NULL
this does make sense.
But is there a way to accomplish this with one statement?
Upvotes: 0
Views: 49
Reputation: 4629
try this http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_nullif
SELECT *
FROM tablename
WHERE IFNULL(colname, 0) <=0;
Upvotes: 1