If I have a list of items, say
apples pairs pomegranites
and I want to identify any that don’t exist in the ‘fruit’ column in an SQL DB table.
- Fast performance is the main concern.
- Needs to be portable over different SQL implementations.
- The input list could contain an arbitrary number of entries.
I can think of a few ways to do it, thought I’d throw it out there and see what you folks think.
Since the list of fruits you are selecting from can be arbitrarily long, I would suggest the following:
A left outer join should be much faster than ‘not in’ or other kinds of queries.