MySQL select statement similar to entered value
I've been searching all over and trying out different approaches but I'm just not getting what I need.
Is there a possibility in MySQL to select a db entry similar to a string value entered in a form?
for example: I have a db with vendor names in it and a customer can enter a vendor name into a search field. Let's say he's looking for adobe but accidentally types 'adope' in the search field. I would now like to select all entries, that are similar to 'adope'. How can I do that?
I've tried ... LIKE '%$vendor%' 开发者_StackOverflowand all kinds of regexp but it seems I'm on the wrong way...
Thanks fpr your help in advance :-)
Cheers
Fred
You can do with SOUNDEX
, check out this tutorial:
- Mysql function to soundex match a word in a multi word string
Also check out the official docs
Returns a soundex string from str. Two strings that sound almost the same should have identical soundex strings. A standard soundex string is four characters long, but the SOUNDEX() function returns an arbitrarily long string. You can use SUBSTRING() on the result to get a standard soundex string.
精彩评论