mysql中not in子查询不能为空

转载自:https://blog.csdn.net/headingalong/article/details/77744755

 

错误sql

 

delete
from
  company_info 
where id NOT in
  (SELECT 
      company_info_ID 
    FROM
      USER);

因为null的原因,导致出现子查询的结果为空。

正确的写法是

 

-- 清除重复的不可用的公司信息    
delete
from
  company_info 
where id NOT in
  (SELECT 
      company_info_ID 
    FROM
      USER
      where company_info_ID is not null);

posted on 2019-09-11 23:24  火龙果果儿  阅读(2175)  评论(0)    收藏  举报

导航