17,140
社区成员




with tmp_Data as (
select 1 ID, Null V_NULL, '' V_STR from dual --空字符跟Null对比
union
select 2 ID, '' V_NULL, '' V_STR from dual --空字符跟空字符对比
union
select 3 ID, Null V_NULL, Null V_STR from dual --NULL跟Null对比
)
select id,
case when v_NULL=V_STR then 1 else 0 end 是否相等,
case when nvl(v_NULL, '') = V_STR then 1 else 0 end 是否相等_NVL
from tmp_Data;
NVL函数,如果为空,后面的参数来替代.
1,select *from 表 where NVL(字段名A,' ') = ' '; --增加空格即可
2,SELECT *FROM 表 WHERE 字段名A IS NULL OR 字段名A = '';
with t as
(
select 'a' id , '' name from dual
union all
select 'b' id , 'bb' name from dual
union all
select 'c' id , 'cc' name from dual
)
--select *from t where NVL(t.name,'') = '';
SELECT *FROM t WHERE t.name IS NULL OR t.name = '';