L
L
Ler Den2018-12-23 01:04:37
PostgreSQL
Ler Den, 2018-12-23 01:04:37

Postgresql how to search a string for a substring from an array of keywords?

I have a filters table with a keywords field of text[] type.
There is an incoming string string. I need to select all lines from filters in which at least one word from the keywords column occurs in string.
Something like this
SELECT * FROM filters WHERE strpos(ANY (keywords), string) >0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Ler Den, 2018-12-23
@givemoneybiatch

It turns out that it is possible

SELECT * FROM public.filter
WHERE 'SQL PostgreSQL' ~ ANY(public.filter.keywords);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question