mysql的not in 导致查询无结果原因

来源:互联网 发布:阿里云服务器ftp在哪 编辑:程序博客网 时间:2024/04/29 13:42

错误sql

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

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

正确的写法是

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



原创粉丝点击