EN
MySQL - soundex usage example
5
points
In this short article, we would like to show how to use Soundex algorithm in MySQL.
Soundex is implemented by default in MySQL by SOUNDEX()
function.
Practical example:
SELECT
SOUNDEX('Robert'), -- R163
SOUNDEX('Rupert'), -- R163
SOUNDEX('Rubin'), -- R150
SOUNDEX('Ashcraft'), -- A2613 (not A226)
SOUNDEX('Ashcroft'), -- A2613 (not A226)
SOUNDEX('Tymczak'), -- T520 (not T522)
SOUNDEX('Pfister'), -- P236
SOUNDEX('Honeyman'); -- H500 (not H555)
Warning: MySQL modifies Soundex algorithm a little to own way.
Output:
R163
R163
R150
A2613
A2613
T520
P236
H500
More complicated example
The below example shows how to group similar words/keywords with SOUNDEX()
.
With SOUNDEX() | Without SOUNDEX() |
Example output: |
Example output: |