数据库 SQL not in

来源:互联网 发布:淘宝零食店一箱零食 编辑:程序博客网 时间:2024/05/18 03:38

在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的数据!

原创粉丝点击