Mysql – sounds like and soundex

Today while looking for some general purpose functions in mysql, I have found an intresting and admiring function which will compare string pronounciations but not the actual strings.

In simple words a function to compare phonetics rather than letters/words.

The function name is soundex. which indeed uses soundex aligorthm

I think this might be an aligorthm being used for spelling suggestions in most places.

See how google shows proper word in Did you mean


Now to be more clear let me explain with an example for you.
In english the word ball and boll both are pronounced similarly although their spellings are different
if we use = operator in mysql as below it will give 0 (zero) as they are not same
select 'ball'=soundex('boll') from dual
But, if we use the function soundex as below it will give 1 as both are pronounced similar.
select soundex('ball')=soundex('boll') from dual


On the other hand sometimes when we have to do a select with where check then we can use sounds like
Sample select with where statement is
select * from toys where toy_name sounds like 'boll'
Sample statement result is(assume toys table has some records)
IdToyname
1boll
2ball
3bol
4bool
4baal

Try urself with some words listed here

principle,principal,princpl
text,test
next,nest
tool,tuul
tie,tih

Thanks for reading - your comments encourage me, Rama Krishna Chunduri
Share