MySQL SOUNDEX Function

MySQL SOUNDEX is one of the String Function, which is to return the Soundex code of a given string. Generally, it returns the four digits standard code as an output of Soundex. However, this is not the case for the long string arguments.

As the name suggests, the string SOUNDEX in MySQL returns the code based on the string sound. I mean, if two strings sound identical, then the Soundex value will be identical too.

MySQL SOUNDEX Syntax

The basic syntax of the SOUNDEX Function in MySQL is as shown below:

SELECT SOUNDEX(String_Expression) FROM [Source]

MySQL SOUNDEX Function Example

The Soundex Function returns the Soundex code value of a user-specified string expression. The following String Soundex query shows you multiple ways to use this function.

SELECT SOUNDEX('Hello');

SELECT SOUNDEX('MySQL');

SELECT SOUNDEX('Suresh');
MySQL SOUNDEX Function 1

Let me show you another MySQL example for better understanding. Within the last statement, we used a NULL value. Remember, SOUNDEX String Function returns NULL for NULL argument value.

SELECT SOUNDEX('Hi');

SELECT SOUNDEX('Hello');

SELECT SOUNDEX(NULL);
MySQL SOUNDEX Function 2