oracle处理情况:
当用空值做判断的时候,可以用nvl函数来处理;
例如:
select * from a t1,b t2
where t1.col1=t2.col1
and t1.col2=t2.col2
and nvl(t1.col3,0)=nvl(t2.col3,0)
意思是当col3为空值的时候,赋值成0再去判断是否相同
postgres处理情况:
可以用coalesce函数处理;
select * from a t1,b t2
where t1.col1=t2.col1
and t1.col2=t2.col2
and coalesce(t1.col3,0)=coalesce(t2.col3,0)
意思是当col3为空值的时候,赋值成0再去判断是否相同
本文介绍在Oracle和Postgres数据库中如何处理空值。使用nvl和coalesce函数将空值转换为0,以便进行比较。适用于数据库开发人员和技术爱好者。

被折叠的 条评论
为什么被折叠?



