tags:

views:

271

answers:

1

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 :)

+1  A: 

Please see:

Mitch Wheat
Based on the examples, I don't think he wants edit distance.
Lukáš Lalinský
Perhaps it will give the poster an idea of how to proceed?
Mitch Wheat