I sometimes interchanged the use of NOT IN and NOT EXIST in my sql queries and both yield the same result. Is the logic behind the NOT EXIST the same as NOT IN? Because I think that NOT IN… (is being evaluated as “OR” inside the subqueries) is equal to NOT EXIST (which is also evaluated as “OR”)? Or am i missing something?
I sometimes interchanged the use of NOT IN and NOT EXIST in my sql
Share
This article may be of interest to you:
In a nutshell,
NOT INis slightly different fromNOT EXISTSin the way the two handleNULLvalues returned by the subquery.If there are no
NULLvalues, they both perform a kind onNESTED LOOP ANTI JOIN, butNOT INis a little bit more efficient.