Finding a suitable prefix for each word in a field in sqlite

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?

+4
source share
1 answer

One option is to use full-text modules; http://www.sqlite.org/fts3.html

 SELECT * FROM table WHERE field MATCH 'phrase*'; 
+2
source

Source: https://habr.com/ru/post/1500299/


All Articles