What\'s the difference between not in
and not exists
in an Oracle query?
When do I use not in
? And not exist
?
There can be performance differences, with exists being faster.
The most important difference is the handling of nulls. Your query might seem to work the same with both in and exists, but when your sub-query returns null you might get a shock.
You might find that the existence of nulls causes exists to fail.
See Joe Celko's 'SQL for smarties' for a better explanation of when to use each.