How to match not null + not empty?

霸气de小男生 提交于 2020-01-12 07:12:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!