zoukankan      html  css  js  c++  java
  • SQL 中 not in 查询不到数据问题

    在开发的过程中,遇到过not in 始终查询不到数据问题

        select * from T_CustomerInfo where CustomerID not in (select CustomerID from T_OrderInfo)

    后来使用not exists查询

    select * from T_CustomerInfo a  where  not exists (select CustomerID from T_OrderInfo where CustomerID=a.CustomerID)

    数据全部都查询出来了

    查看数据,发现T_OrderInfo表中有一条数据中CustomerID为null

    进行修改

    select * from T_CustomerInfo where CustomerID not in (select isnull(CustomerID,NEWID()) from T_OrderInfo)

    这个时候就可以查询出数据

    可以发现not in 遇到null就无效了

    对in进行调查

     select * from T_Task where ID in (select FlowID from T_TaskRecordDetail)

    发现即使T_TaskRecordDetail中FlowID为null,也是可以查询出不为null的数据的

  • 相关阅读:
    Mybatis连接配置文件详解
    MyBatis映射配置文件详解
    AGC 016 C
    CodeForces
    UVA
    某5道CF水题
    DZY Loves Chinese / DZY Loves Chinese II
    [SHOI2016] 黑暗前的幻想乡
    CodeForces
    CodeForces
  • 原文地址:https://www.cnblogs.com/hongdada/p/5169255.html
Copyright © 2011-2022 走看看