From comma separated list to individual item result set. *mysql
Posted
by Raziel
on Stack Overflow
See other posts from Stack Overflow
or by Raziel
Published on 2010-05-06T15:21:03Z
Indexed on
2010/05/06
15:38 UTC
Read the original article
Hit count: 249
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.
© Stack Overflow or respective owner