📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

SOUNDEX



Generates the Soundex code for a string.

  • A Soundex code consists of a letter followed by three numerical digits. TiDB Cloud Lake's implementation returns more than 4 digits, but you can SUBSTR the result to get a standard Soundex code.
  • All non-alphabetic characters in the string are ignored.
  • All international alphabetic characters outside the A-Z range are ignored unless they're the first letter.

See also: SOUNDS LIKE

Syntax

SOUNDEX(<str>)

Arguments

ArgumentsDescription
strThe string.

Return Type

Returns a code of type VARCHAR or a NULL value.

Examples

SELECT SOUNDEX('Datalake'); --- D42 -- All non-alphabetic characters in the string are ignored. SELECT SOUNDEX('Datalake!');; --- D42 -- All international alphabetic characters outside the A-Z range are ignored unless they're the first letter. SELECT SOUNDEX('Datalake,你好'); --- D42 SELECT SOUNDEX('你好,Datalake'); ---342 -- SUBSTR the result to get a standard Soundex code. SELECT SOUNDEX('Datalake Cloud'),SUBSTR(SOUNDEX('Datalake Cloud'),1,4); soundex('datalake cloud')|substring(soundex('datalake cloud') from 1 for 4)| -------------------------+-------------------------------------------------+ D42243 |D422 | SELECT SOUNDEX(NULL); +-------------------------------------+ | `SOUNDEX(NULL)` | +-------------------------------------+ | <null> | +-------------------------------------+

Was this page helpful?