mysql null不参与计算

今天遇到个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 )

才符合实际需求

 

上一篇:继承与多态


下一篇:P2880 [USACO07JAN]平衡的阵容Balanced Lineup 题解