0

I suspect this may not be doable, but I figured I'd try anyway.

In a MySQL database, one of the columns related is a comma-separated list of values: bob,sally,james,rick.

For a given row, the number of items in this column is variable.

Now, if I want to do a soundex search against all the items in that column (client request well after this db has been established and integrated), how would I go about this? I'd want to write something like

SELECT `primary` FROM `table` WHERE `related`.split(",").any() SOUNDS LIKE sample

Which is plainly nonsense code but hopefully conveys the idea.

Essentially, explode/split a CSV field into individual values to SOUNDEX compare. If I have to get all those related fields, explode them and then soundex() them individually in a PHP foreach() loop so be it (that language isn't really important, it could be Python, too, with just a touch more effort), but I'd love to avoid it if possible.

Philip Kahn
  • 614
  • 1
  • 5
  • 22
  • 2
    There are reasons why denormalized databases are hell to work with. You've just found yet another one. – Jonathan Leffler May 12 '14 at 06:08
  • The beauty of roving targets on a WIP. The whole thing started with no databases at all, then the initial one didn't even have a concept of the data in `related`, and so forth ... I never thought I'd be so anxious to refactor all my code. – Philip Kahn May 12 '14 at 06:42

0 Answers0