I have a datset that has product_id, product_url, email, product_title, etc.
I want to pull rows where product_title contains certain adjectives (Fabulous, Stunning, Rare, Amazing, Unique, etc etc. ) from a list of 400+ words.
How do I do this without doing a separate select function for each word? I am using SQLite
Advertisement
Answer
You can construct a single query using or
:
select t.* from t where t.title like '%Fabulous%' or t.title like '%Stunning%' or . . . ;
If the words are stored in a separate table, you could use exists
:
select t.* from t where exists (select 1 from interesting_words iw where t.title like '%' || iw.word || '%' );