I need to query a table like this:
select phrase_id
from direct_words
where knowledge_id = X and dictionary_word_id = Y;
but I only want to retrieve the rows where the same pair (knowledge_id = X and dictionary_word_id = Y) doesn’t exist in another table (top_words). This can be done, applying the query:
select top_id from top_words where knowledge_id = X and dictionary_word_id = Y;
for each returned result from the first query and rejecting if the second query has a row count above 0.
Is this possible to do in a single query to SQLite?
Either the left join as Andrey suggested, or …AND NOT EXISTS ( select x from TOP_WORDS where …. )