Take this table WORDS
WORD
Hello
Aardvark
Potato
Dog
Cat
And this list:
('Hello', 'Goodbye', 'Greetings', 'Dog')
How do I return a list of words that AREN’T in the words table, but are in my list?
If I have a table that “contains all possible words”, I can do:
SELECT * from ALL_WORDS_TABLE
where word in ('Hello', 'Goodbye', 'Greetings', 'Dog')
and word not in
(SELECT word from WORDS
where word in ('Hello', 'Goodbye', 'Greetings', 'Dog')
);
However I do not have such a table. How else can this be done?
Also, constructing a new table is not an option because I do not have that level of access.
Instead of hard coding the list values into rows, use
DBMS_DEBUG_VC2COLLto dynamically convert your delimited list into rows, then use theMINUSoperator to eliminate rows in the second query that are not in the first query: