I have a system that searches for company. I want that when a user searches for \"Demo\", all records that have \"Demo\" will be returned, like \"The Demo\", \"Demo Inc.\",
Try testing for a space at both sides:
select * from table where company LIKE "Demo %" OR company LIKE "% Demo"
However, as you have stated you need to make use of your indexes and anything with a leading wildcard %
won't use the indexes.
Pre-process your record names:
Then when the user searches:
Example stemmed_words Table columns:
id, stemmed_word // Eg. 1 (auto generated), "Demo"
Example record_index Table columns:
record_id, stemmed_word_id, occurrence_count // Eg. 1 (auto generated), 1 (ID of "Demo" in stemmed_words table), 2 (2 occurrences)
Here's a basic tutorial to get you started with stemming and word counts