title: Mysql - Calculate soundex difference between two strings
body: <p>I have some song names and their pre-calculated soundex stored in a mysql table. I want to compare the soundex of user input with the pre-calculated soundex'es. And get the results in ascending order of difference between the user input and song name.</p>
  
  <p>I have tried the following query (in java):</p>
  
  <pre><code>String query="SELECT * FROM song ORDER BY STRCMP(pre_calculated_soundex,SOUNDEX("+user_input+")) ASC ";
  </code></pre>
  
  <p>But strcmp only returns 1,0 or -1. So ordering is not correct.</p>
  
  <p>Also tried <code>WHERE pre_calculated_soundex=SOUNDEX(user_input)</code>, but this just returns exactly matching soundex.</p>