In daily data statistics, try not to use not in to query data. You can consider using exist or left join instead.
However, if in and not in are used, the influence of the null value must be considered, and it cannot be simply understood as not in is the difference of in. For example
raw data
Association Table
Use in
Use not in
It can be seen from the above query results that there are two pieces of data when using the in function to query, but the remaining two pieces of data are not obtained when using not in, but an empty set. This is because there are null values in the result set after not in, and id not in ('','1','2') is equivalent to id<>'' and id <>'1' and id <>' 2', but col<>null is a permanent false type, so the result of the query is an empty set.
Transfer from: https://blog.csdn.net/weixin_40417658/article/details/89333400