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?
This article may be of interest to you:
In a nutshell, NOT IN
is slightly different from NOT EXISTS
in the way the two handle NULL
values returned by the subquery.
If there are no NULL
values, they both perform a kind on NESTED LOOP ANTI JOIN
, but NOT IN
is a little bit more efficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With