what does “delete from table where NULL = NULL” means?

前端 未结 8 1488
抹茶落季
抹茶落季 2021-02-18 12:35

What does delete from table where NULL = NULL mean?

8条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-18 13:18

    It means don't delete anything, because NULL is never equal to anything. Or maybe it means "don't delete anything unless the user's DBMS really sucks, in which case delete it all out of spite".

    Seriously though, that kind of construct usually comes about when a WHERE clause is procedurally generated -- rather than creating a special case for "do nothing", sometimes it's simpler just to generate a WHERE clause that causes the database to do nothing. I've usually seen "WHERE 0 = 1" though, which is less ambiguous.

提交回复
热议问题