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);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM