I am trying to do a comparison between company names using SOUNDEX, but the php call for soundex only outputs 3 digits so the comparisons aren't quite accurate. Is there a way to get a better soundex output so that the results are more accurate?
Asked
Active
Viewed 1,227 times
2 Answers
1
Depending on what you are SOUNDEXing against, it might be cheaper to do run SOUNDEX() at the database level:
$result = $db->query("
SELECT
company.id,
company.name,
SOUNDEX(company.name) AS soundex
FROM
company
WHERE
company.name SOUNDS LIKE '$companyName'
");

Ry Biesemeyer
- 1,484
- 11
- 10
-
should I create within the mysql database itself what the soundex index is ahead of time? – AFG Jan 09 '09 at 18:27
-
In my opinion, the benefits of doing so (marginal performance increase) do not outweigh the pain/expense (keeping the column in sync). I set up a table with 5000 unique names, indexed name column, and ran SOUNDEX on all. Results: 1.8ms average vs 1.5ms for just retrieving the data without SOUNDEX – Ry Biesemeyer Jan 11 '09 at 23:13