如何匹配not null + not empty?

时间:2017-01-30 14:46:40

标签: postgresql postgresql-9.5

我必须对凌乱的数据库进行一些查询。有些列填充了null或空字符串。我可以这样查询:

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

但这种情况有没有捷径? (匹配每个“非空”值)类似于:

select * from a where b is filled;

2 个答案:

答案 0 :(得分:15)

只需:

where b <> ''

将执行您想要的操作,因为null <> ''为null并且不会返回该行

答案 1 :(得分:1)

{settings}