2

I've to match a string with strings in a column of mysql table, i need to select the strings which has more than 80% of match. is there any function in mysql will do this?

for example "quote by placing" string matches more than 80% for the string"quote by place". Like this i've filter.

Thanks!

1
  • Do you have a special reason for "80%"? can you give us some background on what you're doing Commented Jun 9, 2011 at 7:04

4 Answers 4

3

A FULLTEXT search would probably be the best approach for what you're doing. No need to pick an arbitrary % otherwise.

If you're doing more intensive searching check out some of the engines like Sphinx

Sign up to request clarification or add additional context in comments.

3 Comments

i think the best way is using 'like' and match 80% for the result what i get. is it correct.
By using similar_text($str1,$str2,$match) function on search results will give some optimum result i wanted, correct?
Yes, you can use PHP functions like that to analyze your results for the exact % match
0

try chopping 20% of a string in php and then use like for 80% of your string and all strings to compare

4 Comments

I might be wrong, but I think he wants 80% that appears anywhere, not just the start. So cutting it would only compare a certain 80% that you pick
@babonk yes, i just want to match 80% anywhere on the string not the start
oh, so i'm sorry for misunderstanding the question
@banonk i want to some options to be selected by default on the basis of this match.
0

You could try looking at the MYSQL soundex function that may give you what you need

Comments

0

As far as I understand your criteria, you want a fuzzy search. This is not implemented in MySQL. You will have to find a way to externalize the check for this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.