使用 not in 加子查询的 查询语句,测试数据库 上好好的,线上项目查不出数据,
数据库数据是存在的
发现 问题出在 not in 后 有为null 的数据 所以没有数据返回 null什么都不能当 null 与ID进行匹配 返回 false
所以 一条数据也不会返回
原始sql
select * from xx where id not in (‘1’,’2’,null);
更改
select * from xx where id not in ( select * from xxx where id is not null );