0

I want to find the similar for an existing row according to the value of a column. I try to explain by an example.

----------------------------
 id |  name   |   username
----------------------------
 1  |  Ahmet  |    amini
----------------------------
 2  |  Nima   |    azimzadeh
----------------------------
 3  |  Akbar  |    amiini
----------------------------

I have a username value like samins and what I want is fetch row 1 and row 3 as similars of samins.

So I want a result like this:

----------------------------
 id |  name   |   username
----------------------------
 1  |  Ahmet  |    amini
----------------------------
 3  |  Akbar  |    amiini
----------------------------

Is there any way to do this with MySQL?

Behnam Azimi
  • 2,260
  • 3
  • 34
  • 52

1 Answers1

0

Maybe this will help :

SELECT * FROM TableName WHERE soundex(`username`) = soundex('samins');

Soundex is a phonetic algorithm for indexing names after English pronunciation of sound.

The SOUNDEX() function has following limitations :

  • This function, as currently implemented, is intended to work well with strings that are in the English language only. Strings in other languages may not produce reliable results.
  • This function is not guaranteed to provide consistent results with strings that use multi-byte character sets, including utf-8.

More reading on soundex : these:http://www.postgresonline.com/journal/archives/158-Where-is-soundex-and-other-warm-and-fuzzy-string-things.html

From : https://stackoverflow.com/a/41629952/10412218

Bogdan N.
  • 360
  • 1
  • 8