SOUNDEX

From MidrangeWiki
Jump to: navigation, search

Overview

Soundex is an algorithm that converts a character string into a four character code consisting of a letter followed by a three-digit number that represents the general sound associated with the remainder of the word. For example, both FISH and FICHE return soundex code F200.

select soundex('FISH'), soundex('FICHE') from QSQPTABL

SOUNDEX ( 'FISH' )  SOUNDEX ( 'FICHE' )
       F200                F200        

Usage

The SQL function SOUNDEX can be used to find a character string for which the sound is known, but the exact spelling is not. For example, the following searches the file for a name that sounds like prtsit and returns the name Pritchett.

From Command Line or equivalent STRSQL

SELECT fieldname FROM libraryname/filename WHERE SOUNDEX{fieldname) = SOUNDEX('prtsit') ORDER BY fieldname