美文网首页
Oracle not in 的坑

Oracle not in 的坑

作者: 橘猫吃不胖 | 来源:发表于2020-06-18 15:29 被阅读0次

    刚刚发现个数据问题,排查了下,结果又是oracle的坑,记录下

    这次是关于not in的问题

    select *from 
    from v_xy_new_small_b a
    where a.user_code not in (select user_code from v_xy_meigu_and_empployee)
    

    我就是想剔除下重复的用户,结果发现,今天查不出数据了,昨天还是正常的,找了半圈,发现是Oracle的一些特性

    如果这个子查询中,结果中有NULL值,那就会返回空结果集

    后来一看的确是我的v_xy_meigu_and_empployee中有user-code为空的记录,

    修改下:

    select *from 
    from v_xy_new_small_b a
    where a.user_code not in (select user_code from v_xy_meigu_and_empployee where user_code is not null)
    

    相关文章

      网友评论

          本文标题:Oracle not in 的坑

          本文链接:https://www.haomeiwen.com/subject/zwyuxktx.html