views:

55

answers:

3

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.

+2  A: 

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.

Manoj Govindan
+2  A: 

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.

Pekka
+1  A: 

try

similar_text()
levenshtein() 
soundex()

Please check,

http://php.net/manual/en/function.similar-text.php

Yogesh