--- In [email protected], James Keeline <[EMAIL PROTECTED]> wrote:
>
> --- andrew_maben <[EMAIL PROTECTED]> wrote:
>
> > A match on the initial letters is much too loose, an exact match is too
> > stringent. We're looking for the middle ground, erring (but not too far)
> > on the generous side.
> >
> > Any ideas?
> >
> > Thanks in advance for any light you may be able to shed.
> >
> > Andrew
>
> You may need to make up your own synonym lists. However, the soundex()
> function for both PHP and MySQL is designed to address much of what you
> describe.
>
> Definition: http://en.wikipedia.org/wiki/Soundex
> PHP function: htpt://php.net/soundex
> MySQL function:
> http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_soundex
>
> James
>
Thanks, James. Yes I was thinking about soundex - how about:
$first_part = substr($first_name,0,3) . '%';
$last_part = substr($last_name,0,3) . '%';
$sql = "SELECT first_name, last_name
FROM names_table
WHERE ((first_name LIKE '$first_part'
AND last_name LIKE '$last_part')
OR (STRCMP(SOUNDEX(first_name), SOUNDEX('$first_name')) = 0
AND STRCMP(SOUNDEX(last_name), SOUNDEX('$last_name')) = 0)";
I'm going to do some tests based on this - any further thoughts would be very
welcome.
Andrew