Mysql - Calculate soundex difference between two strings -


i have song names , pre-calculated soundex stored in mysql table. want compare soundex of user input pre-calculated soundex'es. , results in ascending order of difference between user input , song name.

i have tried following query (in java):

string query="select * song order strcmp(pre_calculated_soundex,soundex("+user_input+")) asc "; 

but strcmp returns 1,0 or -1. ordering not correct.

also tried where pre_calculated_soundex=soundex(user_input), returns matching soundex.

completely low-tech , assuming first 4 characters of soundex function being used , assuming "aaaa" user input

  select *    song  order  substr(pre_calculated_soundex, 1, 1) =                      substr(soundex("aaaa"), 1, 1)                                                   + substr(pre_calculated_soundex                      , 2, 1) =                      substr                      (soundex("aaaa"), 2, 1)                      + substr(pre_calculated_soundex, 3, 1)                      = substr(soundex("aaaa"), 3, 1)                        + substr(pre_calculated_soundex, 4, 1                        )                        = substr(soundex("aaaa"), 4, 1)  

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -