I'm working with a MySQL database that hold metaphone keys of a string (peoples names) in a VARCHAR field but I'm having a problem when it comes to pulling out individuals with multiple names.
As an example, take the metaphone key for "Mary Ann", which is stored in the database (space delimited) as "MR AN". If I wanted to pull out all "Mary's" (MR), I could do :-
WHERE firstname = 'MR';
But this wouldn't pull out "Mary Ann" (MR AN) as well which I want to do. I could try :-
WHERE firstname LIKE '%MR%';
But this has the danger of possibly pulling out other metaphone keys with "MR" in them that aren't Marys. It's a similar issue with short names like "Lee" where the metaphone key is just "L". Doing a "LIKE '%L%'" could potentially return millions of other names ...
So my question is what is the best approach to this? How can I pull out individual metaphone keys that are in one field, space delimited? Do I need some sort of regular epression within a select statement for this?