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

xiaoxiao2021-02-28  120

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

转载请注明原文地址: https://www.6miu.com/read-31106.html

最新回复(0)