问题
I have to do some queries on a messy database. Some columns are filled with either null or empty string. I can do query like this:
select * from a where b is not null and b <> '';
But is there a shortcut for this case? (match every "not empty" values) Something like:
select * from a where b is filled;
回答1:
Just:
where b <> ''
will do what you want as null <> '' is null and the row will not be returned
回答2:
select * from a where COALESCE(b, '') <> '';
来源:https://stackoverflow.com/questions/41938704/how-to-match-not-null-not-empty