I need to write a SELECT
, selecting lines where the prefix of any word from some field matches the given pattern. I am using sqlite, but this is a general question.
I came up with two ideas:
SELECT (...) FROM table WHERE field LIKE 'phrase%' OR field LIKE '% phrase%'
or
SELECT (...) FROM table WHERE ' ' || field LIKE '% phrase%'
Both do not look very elegant, and when I use more ... OR ... LIKE ...
in one SELECT
, it kills query performance.
Is there any way to handle this better?
source share