一个奇怪的现象
在sql server和oracle中有这样一个奇怪的现象:
在sql server中:
select case when '1'<>' ' then 'ok' else 'no' end
select case when '1'<>'' then 'ok' else 'no' end
这两条语句的返回值都为OK
但是,在oracle中:
select case when '1'<>'' then 'ok' else 'no' end from dual;
这个返回值为no
select case when '1'<>' ' then 'ok' else 'no' end from dual;
这个返回值为OK
这种现象该怎么解释呢?
oracle里''表示null,null不是等于且不是不等于其他任何值 (有点拗口……) ^_^
oracle中'' 和' '是两个不同概念的东西,前者代表null,后者代笔一个空格,null不能直接拿来和字符做对比,应该nvl后再做比较 sql server中两者意思一样 所以是可以的