如何选择null或零长度?

时间:2014-11-19 22:05:07

标签: sql postgresql

我有疑问:

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

但是我希望显示text_b不为null且text_b的长度为>的结果。 0。 怎么做?

1 个答案:

答案 0 :(得分:3)

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

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

或正确处理null

中的text_b
select text_b, id 
from articles 
where title is not null
  and text_b is distinct from '';
相关问题