SQL:如何强制关系运算符考虑NULL值

Uda*_*day 3 mysql sql where-clause

我有2个表(TABLE1和TABLE2).我想执行以下查询:

UPDATE TABLE1 a,TABLE1 b
SET a.desg=CASE WHEN b.attribute_id=74 THEN b.value ELSE a.desc END
WHERE a.entity_id=b.entity_id;
Run Code Online (Sandbox Code Playgroud)

但我在TABLE1中有一些行,其中entity_id为NULL.
在评估时不考虑这些WHERE a.entity_id=b.entity_id;

我甚至想要为这个WHERE子句考虑NULL.

我怎样才能做到这一点?提前致谢.

lev*_*evi 5

UPDATE TABLE1 a, TABLE1 b
SET a.desg = CASE WHEN b.attribute_id=74 THEN b.value ELSE a.desc END
WHERE a.entity_id=b.entity_id OR (a.entity_id IS NULL AND b.entity_id IS NULL)
Run Code Online (Sandbox Code Playgroud)