Let's say we have a table with column "titles" like this:
| title |
|---|
| The Colour of Magic |
| The Light Fantastic |
| Equal Rites |
| Wyrd Sisters |
| Reaper Man |
and filtering words like this
filter_words = ['Man', 'Sisters']
The main idea I came up to is to convert filter_words from array to table like this
select arrayJoin(['Man', 'Sisters']) as filter_word
and join on some condition. I've tried this condition but got an exception that condition is not supported. what is the correct way to filter column by string part?
JOIN filter_words
ON position(not_filtered.title, filter_words.filter_word) > 0
JOIN filter_words
ON '%' + filter_words.filter_word + '%' like not_filtered.title
You may split the initial string to array of tokens and use a handy hasAny function to check if two arrays have intersection by some elements.
The result is: