MySQL query, get the closest if exact not found

Hi,

How do I write a query that returns the closest / best matches if exact is not found? The best implementation can be seen on google.com that says "Did you mean _______" Now a days they have changed it and show the result for the correct keyword by default and shows "Search instead for ________" below it.

E.g. searching for:
fung shui
fungshwe

or any other spelling variation always results in correct one i.e. feng shui

Thanks
practitionerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim P.Commented:
Basically you would have to build up an index table that has the correct word and the variants that are off. Then you also have have to build a probability function so if someone were to type in "italian piza seattle" that you feed back the says "Did you mean pizza, Seattle Washington?" versus "Did you mean Pisa Italy?"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
practitionerAuthor Commented:
Thanks Tomas, Soundex function is the key.

Thanks jimpen, building an index is very difficult, although soundex is the implementation I need at the moment, I would love to know the best approach to build such an index automatically, I believe Google wouldn't have done this manually because it's almost impossible.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.