Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- mysql search close result
- Bob Bedford
July 20, 2005, 12:10 pm
rate this thread
I've to find in a table the "closer" result given some text.
Here is a little example:
given the text "Batman socks" I've to find the best matching result in
-"batman black socks" ->this should be found
or given the text "leather shoes" I've to find the best matching result in
-"shoes" ->this should be found
My problem is to get the best choice where I've too many informations in the
I mean using - like '%Batman%' and like '%socks%'- will work for the first
case, but not the second.
Any idea ?
Re: mysql search close result
The trick is that you use an algortihm that seeks the nearest difference
between two texts.
Use the 'levenshtein' function. However the Problem might be that you
have to go through your database sequentially.
I've programmed somthing for single words (to suggest oranges when
orangse are typed). In that case the soundex function did a lot of work
to get a smaller subset of the database.
I'm afraid that if the database is very large, the world will be saved
by a barefooted batman. Tasty!