Left join input list to the target table/column and keep rows having NULL in the fields from the “words” table.
WITH
query_input(word) AS (
VALUES ('word 1'), ('word 2'), ('word 0'), ('word 3'), ('word 5')
),
-- Remove this CTE when querying against your db.
dict(id, word, definition) AS (
VALUES
(1, 'word 1', 'definition 1'),
(2, 'word 2', 'definition 2'),
(3, 'word 3', 'definition 3')
),
new_words AS (
SELECT query_input.*
FROM query_input
LEFT JOIN dict ON query_input.word = dict.word
WHERE dict.id IS NULL
)
SELECT * FROM new_words;
0
solved Find all records which does not exist in table sqlite [closed]