在SQL 中,not in 语句用法:
select * from hd123 where 号码 not in ( select phone from pusersinfo );
语句作用是查询出表hd123中号码不在pusersinfo中;但是有时候这个结果是错误的;
正确的语句是下面:
select * from hd123 where 号码 not in ( select phone from pusersinfo where phone is not null )。
过滤掉phone 是NULL的数据!
本文介绍了SQL中notin语句的正确使用方法,避免因忽略NULL值而导致查询结果不准确的问题。通过示例展示了如何正确地排除NULL值,确保查询结果的准确性。
283

被折叠的 条评论
为什么被折叠?



