I have a table which looks something like this - where the second and third columns have strings. I would like to split the string (delimited by commmas)
Asked
Active
Viewed 67 times
1
-
1Exploding CSV will probably require a user-defined function, and I don't expect it to not be ugly. Is there any chance you can normalize your data before it even hits MySQL? – Tim Biegeleisen Oct 17 '16 at 21:03
-
That second table is still missing the rest of the data right? – Jorge Campos Oct 17 '16 at 21:07
-
@JorgeCampos. Yeah, the second table is missing data. it would continue my exploding apple and orange for BBC and EFG. – Sankar Muthuswamy Oct 17 '16 at 21:10
-
@TimBiegeleisen - What do you mean my normalize? Like export it to another tool? – Sankar Muthuswamy Oct 17 '16 at 21:11
-
@SankarMuthuswamy No, I was thinking more along of the lines of normalizing it before it even comes in MySQL. Get rid of that CSV data if at all possible. – Tim Biegeleisen Oct 17 '16 at 21:12
-
The problem comes as each row has different number of "fruits" under Col A. and a similar issue with Col B. @TimBiegeleisen – Sankar Muthuswamy Oct 17 '16 at 21:14
-
1I see the problem, no need to explain it to me. But do you see the problem here? You have, in a single record, a collection of fruits which are in some related to a collection of labels. But it is impossible to say _what_ this relationship is, not without external information. – Tim Biegeleisen Oct 17 '16 at 21:16
-
There's no built-in way to split a string in MySQL. See http://stackoverflow.com/search?q=%5Bmysql%5D+split+string for some of the workarounds. – Barmar Oct 17 '16 at 21:19
-
@TimBiegeleisen. Yeah, I see the issue. Right now this explosion of the table is being handled manually. I'm seeing if its possible to automate it. – Sankar Muthuswamy Oct 17 '16 at 21:19
-
You can use this solution: http://stackoverflow.com/a/17942680/460557 It is not pretty but it will do the job. – Jorge Campos Oct 17 '16 at 21:58