Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to match not null + not empty?

I have to do some queries on a messy database. Some columns are filled with either null or an empty string. I can do a 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" value) Something like:

select * from a where b is filled;
like image 307
rap-2-h Avatar asked Jan 30 '17 14:01

rap-2-h


1 Answers

Just:

where b <> ''

will do what you want as null <> '' is null and the row will not be returned

like image 82
Clodoaldo Neto Avatar answered Oct 05 '22 11:10

Clodoaldo Neto