0

I have query:

select text_b, id from articles where title is not null;

But i want to show results where text_b is not null and length of text_b > 0. How to do it?

Nips
  • 13,162
  • 23
  • 65
  • 103

1 Answers1

3
select text_b, id 
from articles 
where title is not null
  and length(text_b) > 0;

or

select text_b, id 
from articles 
where title is not null
  and text_b <> '';

or to properly handle null values in text_b

select text_b, id 
from articles 
where title is not null
  and text_b is distinct from '';
  • 1
    @Nips: `text_b <> ''` is *all* you need. Details [here](http://stackoverflow.com/questions/23766084/best-way-to-check-for-empty-or-null-value/23767625#23767625). – Erwin Brandstetter Nov 19 '14 at 22:23