【问题标题】:strange behavior with 'IN' clause works'IN' 子句的奇怪行为有效
【发布时间】:2011-04-02 17:02:57
【问题描述】:

我找到了这个网站:here

它很好地描述了它为什么有效,为什么不有效。

但我的问题有点不同。

select 'true' from dual where 'test' not in ('test2','');

为什么这个查询不返回一行?
'' 是否像 null 一样处理?

感谢您的帮助

【问题讨论】:

  • 我不确定(我是 SQL Server 人员),但我认为 Oracle 确实将 '' 视为 null。
  • @APC - 不是真的。这个问题是does it...? 不是why does it...?
  • @MartinSmith - 我认为这个问题的答案也回答了这个问题。所以在某种程度上它是重复的。

标签: sql oracle null behavior string


【解决方案1】:

是的,在 Oracle 中,空字符串是 NULL。

【讨论】:

    【解决方案2】:

    你的怀疑were correct

    所以你的查询基本上是

    WHERE 'test' <> 'test2' and  'test' <> Null
    

    计算结果为

    WHERE true and unknown
    

    unknown

    select * from dual where '' = '';
    

    会给出相同(缺乏)的结果

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-24
      • 2012-05-09
      • 1970-01-01
      • 1970-01-01
      • 2017-03-29
      • 2014-10-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多