How to combine non null + not empty?

I need to make some queries in a messy database. Some columns are either null or empty. I can make a request as follows:

 select * from a where b is not null and b <> ''; 

But is there a shortcut for this case? (corresponds to each "non-empty" value) Something like:

 select * from a where b is filled; 
+5
source share
2 answers

Just:

 where b <> '' 

will do what you want since null <> '' is null and the string will not be returned

+7
source

select * from a where COALESCE(b, '') <> '';

+1
source

Source: https://habr.com/ru/post/1263586/


All Articles