I'm doing some data migration from a horribly designed database to a less horribly designed database. There is a many to many relationship that has a primary key in one table that corresponds to a comma separated list in another.
FK_ID | data
-------------
1,2 | foo
3 | bar
1,3,2 | blarg
Is there a way to output the FK_ID field with each comma separated element as a single line in the result set?
result set
FK_ID | data
-------------
1 | foo
2 | foo
3 | bar
1 | blarg
2 | blarg
3 | blarg
I'm thinking this would require some sort of recursive query which I don't think mysql has.
Thanks in advance.