Oracle not in 的坑

剛剛發現個數據問題,排查了下,結果又是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)
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。