0

I need something softer than SOUNDS LIKE or I need to configure it abit.

I have table with cities for example: "London" I want to have up to one letter mistake in query.

When user will write: "Londom", I still want MYSQL to select London. But if user will write London with 2 letters wrong I don't want to select London anymore. So I just want SOUNDS LIKE with 1 letter treshold.

Pikachu
  • 1,973
  • 3
  • 20
  • 27
  • 1
    Sounds like you're looking for an [Edit Distance](http://en.wikipedia.org/wiki/Edit_distance) match. Problem is that these kinds of matches are *really* expensive, since indexing can't help make them faster, and you'll typically have to implement it by hand. – Gustav Bertram Apr 14 '14 at 08:02

1 Answers1

2

Sounds/Soundex will be useless in this case:

There is solution:

how to compute similarity between two strings in MYSQL

Yo Can do this also in PHP- using levenshtein() function:

<?php
$sMySTR = "London";

$string1 = "Londam";
$string2 = "Londom";
$string2 = "London";

$check1 = levenshtein(sMySTR, $string1);
$check2 = levenshtein(sMySTR, $string2);
$check3 = levenshtein(sMySTR, $string3);

echo $check1." "; 
echo $check2." "; 
echo $check3." "; 
?>

Output will be:

2 1 0

Community
  • 1
  • 1
Andrzej Reduta
  • 767
  • 1
  • 7
  • 15