SQLite Tutorial SQLite Advanced SQLite Database SQLite References

SQLite SOUNDEX() Function



The SQLite SOUNDEX() function returns a soundex string from a given string. Two strings that sound almost the same should have identical soundex strings. A standard soundex string is four characters long. The string "?000" is returned if the argument is NULL or contains no ASCII alphabetic characters.

This function is omitted from SQLite by default. It is only available if the SQLITE_SOUNDEX compile-time option is used when SQLite is built.

Syntax

SOUNDEX(str)

Parameters

str Required. Specify a string whose soundex string is to be retrieved.

Return Value

Returns the soundex string from a given string.

Example 1:

The example below shows the usage of SOUNDEX() function.

sqlite> SELECT SOUNDEX('Hello');
Result: 'H400'

sqlite> SELECT SOUNDEX('Principal');
Result: 'P652'

sqlite> SELECT SOUNDEX('Principle');
Result: 'P652'

Example 2:

Consider a database table called Sample with the following records:

DataWords
Data1Here
Data2Heir
Data3Smith
Data4Smythe
Data5To
Data6Too
Data7Two

To get the soundex string of all records of Words column, the following query can be used:

SELECT *, SOUNDEX(Words) AS SOUNDEX_Value FROM Sample;

This will produce a result similar to:

DataWordsSOUNDEX_Value
Data1HereH600
Data2HeirH600
Data3SmithS530
Data4SmytheS530
Data5ToT000
Data6TooT000
Data7TwoT000

❮ SQLite Functions