Making query shorter

To search within a database with a lot of text i’m now using

column like ‘%text%’

but this query will also include a lot of words I do not need.

This is a test
Istesto in abo
Test this phrase

Now when I query it with the above column like ‘%test%’ i will get all three… but the 2nd is bogus.

Though i can not do
column like ‘% text%’
including a space, because it would not get the 3rd too…

So the problem is:
How to query using % % (and a third something?) so that it will also get the 3rd result (with the word at the very beginning), but that it will make sure it’s a word, not part of the word.

p.s. No I can not use fulltext as the words are to short, this is the backup script if fulltext fails )


You can configure MySQL Full Text Search to use no stop words and have no minimum length if this is what you need for your application.

This is probably best way for you.

If not look at using regular expressions to identify you require whitespace from both sides of the string.