如何匹配not null + not empty?
How to match not null + not empty?
我必须在凌乱的数据库上做一些查询。某些列填充有 null
或空字符串。我可以这样查询:
select * from a where b is not null and b <> '';
但是这种情况有捷径吗? (匹配每个“非空”值)类似:
select * from a where b is filled;
select * from a where COALESCE(b, '') <> '';
刚刚:
where b <> ''
将执行您想要的操作,因为 null <> ''
为空并且不会返回该行
我必须在凌乱的数据库上做一些查询。某些列填充有 null
或空字符串。我可以这样查询:
select * from a where b is not null and b <> '';
但是这种情况有捷径吗? (匹配每个“非空”值)类似:
select * from a where b is filled;
select * from a where COALESCE(b, '') <> '';
刚刚:
where b <> ''
将执行您想要的操作,因为 null <> ''
为空并且不会返回该行