Soundex is the algorithm for indexing names by sound or as pronounced. The MySQL SOUNDEX() function returns a Soundex string from a string supplied.
It can also be used to find same-sounding strings from a table.
The example people table:
| id | first_name | |----|------------| | 1 | Aiden | | 2 | Aidan | | 3 | Ryan | | 4 | Tim | | 5 | Ayden | | 6 | Matt | | 7 | Aydin |
You can see there are several “aidens” but they are spelt different however essentially pronounced the same.
This is where SOUNDEX() can help because using a LIKE query will not.
An example SOUNDEX() query to get all names that sound like “aiden”
SELECT `id`, `first_name` FROM `people` WHERE soundex("aiden") = soundex(first_name); The result:
| id | first_name | |----|------------| | 1 | Aiden | | 2 | Aidan | | 5 | Ayden | | 7 | Aydin |
SOUNDEX() does its job in finding the values that sound the same as “aiden”.
SELECT `id`, `first_name` FROM `people` WHERE soundex("aidn") = soundex(first_name); Returns the same results, however using soundex("aid") returns nothing, because it doesn’t sound like Aiden.
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Some early September spring shots from a bushwalk, It is still too early for wildflowers.
I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…
If you ever needed a simple solution in Laravel to delete an entire directory and…
How to enforce only one user to register or be registered in a Laravel web…