NOT IN does not produce same results as NOT EXISTS

前端 未结 2 981
滥情空心
滥情空心 2021-01-22 19:27

These are rather basic statements. I have a list of graphics which are linked to items in another table. I want to check how many of the graphics are not in use and can theoreti

2条回答
  •  不知归路
    2021-01-22 20:13

    NOT IN with a subquery has strange behavior. If any row in the subquery returns a NULL value, then no rows are returned. This is due to following the strict semantics of NULL (which means: "I don't know if they are equal").

    NOT EXISTS behaves as you would expect. For this reason, I recommend never using NOT IN with a subquery. Always use NOT EXISTS.

提交回复
热议问题