mysql null不参与计算 AlanTuring

今天遇到个bug 先看原sql:
delete p  from qtylabelspromgdinfo p, goods g where g.Code = p.SpuCode and p.bufferid = 'edebb561-a350-42ed-85f3-7c917f7a0307' and p.storecode = '4846' and g.storecode = '4846'  and p.queryuuid = '68defa53-f5b2-4729-a9a8-b21b5ce6f121' and ( g.f1 NOT IN ('0') )

结果删除完的数据,除了f1为0的,还存在一堆f1=null的数据

修改完:

delete p  from qtylabelspromgdinfo p, goods g where g.Code = p.SpuCode and p.bufferid = 'edebb561-a350-42ed-85f3-7c917f7a0307' and p.storecode = '4846' and g.storecode = '4846'  and p.queryuuid = '68defa53-f5b2-4729-a9a8-b21b5ce6f121' and ( g.f1 NOT IN ('0') or g.f1 is null )

才符合实际需求

原文地址:https://www.cnblogs.com/alanturingson/p/15693960.html