Display similar results from mySQL
How can I create a query that will return similar words if an exact match is not found? For example if the query is trying to match "mstke" and if the word is not found in the database then results 开发者_开发知识库should contain similar words like "mistake", "misstep", "take" and "mist".
I tried %LIKE%
, but it displays the exact match of words.
You could take a look whether SOUNDEX()
works for you. I expect it won't work for every example you give but maybe for some.
Here is a blog article giving a more in depth look.
You should explore the Soundex option. Soundex will match similar sounding words. Using soundex you will be able to match some but NOT all of the words in your example.
try
similar_text()
levenshtein()
soundex()
Please check,
http://php.net/manual/en/function.similar-text.php
精彩评论