SOUNDEX

The SOUNDEX function returns a 4 character code representing the sound of the words in the argument. The result can be used to compare with the sound of other strings.

SOUNDEX(expression)
expression
An expression that returns a value of any built-in numeric or string data type, that is not a CLOB or DBCLOB. The argument cannot be a binary string. A numeric argument is cast to a character string before evaluating the function. For more information about converting numeric to a character string, see VARCHAR.

The data type of the result is CHAR(4). If the argument can be null, the result can be null; if the argument is null, the result is the null value.

The CCSID of the result is the default CCSID of the current server.

The SOUNDEX function is useful for finding strings for which the sound is known but the precise spelling is not. It makes assumptions about the way that letters and combinations of letters sound that can help to search out words with similar sounds. The comparison can be done directly or by passing the strings as arguments to the DIFFERENCE function. For more information, see DIFFERENCE.

Example

  • Using the EMPLOYEE table, find the EMPNO and LASTNAME of the employee with a surname that sounds like 'Loucesy'.
      SELECT EMPNO, LASTNAME
             FROM EMPLOYEE
             WHERE SOUNDEX(LASTNAME) = SOUNDEX('Loucesy')
    Returns the row:
    000110 LUCCHESSI