Sunday, March 20, 2011

MySQL String match percentage

In MySQL, how can I compare two strings and get matching percentage. Something like this:

compare(needle, haystack) = percentage

compare("foo", "food") = 0.75
compare("foo", "foobar") = 0.5
compare("foo", "foofoo") = 1.0
compare("foo", "fo") = 0.0

I hope you get the idea :)

From stackoverflow

0 comments:

Post a Comment