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.
Using FTP and PHP to get an array of file details such as size and…
Creating and using Laravel form requests to create cleaner code, separation and reusability for your…
Improving the default Laravel login and register views in such a simple manner but making…
Laravel validation for checking if a field value exists in the database. The validation rule…