soundex, difference

The soundex function converts a character string to a four-digit code for use in a comparison. It ignores vowels in the comparison. Nonalphabetic characters terminate the soundex evaluation. This function always returns some value. These two names have identical soundex codes:

select soundex ("smith"), soundex ("smythe") 
----- -----  
S530  S530 

The difference function compares the soundex values of two strings and evaluates the similarity between them, returning a value from 0 to 4. A value of 4 is the best match. For example:

select difference("smithers", "smothers") 
--------- 
        4
 
(1 row affected)
select difference("smothers", "brothers") 
 --------- 
         2 
 
(1 row affected)