zoukankan      html  css  js  c++  java
  • (008)每日SQL学习:Oracle Not Exists 及 Not In 使用

    今天遇到一个问题,not in 查询失效,我以为是穿越了,仔细查了点资料,原来理解有误!

    select value from temp_a a
    where a.id between 1 and 100
    and not exists(select * from temp_b b where a.value=b.value);

    这时能查出结果

    select value from temp_a a
    where a.id between 1 and 100
    and a.value not in(select value from temp_b);

    此时查出的结果为空.

    经过google终于找出原因: 内表(temp_b)有空值. 用not in得到的结果集都为空.以下是结论:

    1、对于not exists查询,内表存在空值对查询结果没有影响;对于not in查询,内表存在空值将导致最终的查询结果为空。

    2、对于not exists查询,外表存在空值,存在空值的那条记录最终会输出;对于not in查询,外表存在空值,存在空值的那条记录最终将被过滤,其他数据不受影响。

    本文转自:http://blog.csdn.net/haitaofeiyang/article/details/50158395

  • 相关阅读:
    MongoDB 基础API使用
    MongoDB -- JAVA基本API操作
    Docker数据管理
    Docker容器的简单使用
    Docker
    Centos 7.3 镜像制作
    Fuel部署OpenStack
    Fuel
    Ceph添加、删除osd及故障硬盘更换
    ceph常用命令
  • 原文地址:https://www.cnblogs.com/littlewu/p/8297854.html
Copyright © 2011-2022 走看看