Either use
SELECT IF(field1 IS NULL or field1 = '', 'empty', field1) as field1
from tablename
or
SELECT CASE WHEN field1 IS NULL OR field1 = '' THEN 'empty' ELSE field1 END AS field1 FROM tablename
If you only want to check for
null
and not for empty strings then you can also use ifnull
as you tried. But that is not suitable for empty strings too.
0 comments:
Post a Comment