I have a list of values, and want to know which ones don't already exist in the table. (This is on sql server 2000)
Consider the following:
CREATE TABLE myTable ( foo VARCHAR(10) )
GO
INSERT INTO myTable
( foo
)
SELECT 'aaa'
UNION ALL SELECT 'bbb'
UNION ALL SELECT 'ccc'
GO
SELECT foo
FROM myTable
WHERE foo IN ( 'aaa', 'cat', 'bbb', 'dog' )
-- returns 'aaa' and 'bbb'
I need to write a query that returns 'cat' and 'dog'.
SELECT foo
FROM myTable
WHERE foo ????? ( 'aaa', 'cat', 'bbb', 'dog' )
-- returns 'cat' and 'dog'
Is there a simple way to do this in a query?
Due to the way the app interacts with the database, I'd rather not, say, create a temp table