kbhao7788 2017-04-29 00:45 采纳率: 0%
浏览 1061
已采纳

Oracle null的问题帮忙解决一下

select * from emp where comm not in (null);
select * from emp where comm in (null);
为什么都没有输出东西

  • 写回答

2条回答 默认 最新

  • 战在春秋 2017-04-29 08:28
    关注

    如下引自官方文档 (本来想翻译的,不过原文更准确)

    A null can be assigned but it cannot be equated with anything, including itself. NULL values represent missing or unknown data. NULL values are not an integer, a character, or any other specific data type. Note that NULL is not the same as an empty data string or the numerical value '0'.

    null 不能用 = 与任意值比较,甚至包括null 本身,也就是说即便是 null = null 也是没有意义的。

    select * from emp where comm not in (null); 相当于比较comm = null
    select * from emp where comm in (null); 相当于比较comm != null
    这二行语句都是无效语句
    

    oracle 有专门的 IS [NOT] NULL,用于测试表达式是否为null值。

    例如:

    SELECT *
    FROM suppliers
    WHERE supplier_name IS NULL;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考