I have a mysql legacy table which contains an client identifier and a list of items, the latter as a comma-delimited string. E.g. \"xyz001\", \"foo,bar,baz\"
. T
Interesting.
I can't think of a clean and tidy solution, but I could offer some ideas.
I guess you could combine UNION with the following:
http://blog.fedecarg.com/2009/02/22/mysql-split-string-function/
If you know the maximum number of items in any row, then you could do a union on the results .. something like:
(SELECT col1, SPLIT_STR(col2, ',', 1) c2 from tbl)
UNION (SELECT col1, SPLIT_STR(col2, ',', 2) c2 from tbl where col2 like '%,%')
UNION (SELECT col1, SPLIT_STR(col2, ',', 3) c2 from tbl where col2 like '%,%,%')
...
I'm not very up on mysql stored procedures, but perhaps you could do some clever stuff with loops in order to make this more dynamic.
I hope this points you in the right direction - ?