I know this is far from the optimal way of doing things, but it is something that needs to be done infrequently, so I don't want to look at modifying the database / applications.
I have a database field DataField (BLOB) which contains a string of data in the format:
"1,,0,13424556,item,something"
however that field may contain multiple instances (Sometimes 4 or 5 instances)e.g.
"1,,0,13424556,item,something\r\n"1,,1,12345888,itemOther,somethingElse"
I need to find a way (in MySQL) to split this up to display each item individually (in it's own column). But can't find a way of doing this. (In fact if at all possible I need just the number string from each one (e.g.
13424556
))
I have the below query which is a start:
SELECT
SUBSTRING_INDEX(`DataField`,'\r\n',1),
SUBSTR(`DataField`, LOCATE('\r\n',`DataField`)+2, (CHAR_LENGTH(`DataField`) - LOCATE('\r\n',REVERSE(`DataField`) )- LOCATE('\r\n',`DataField`))) AS e2
FROM table3;
This works if there are only two items, but not if there are 3 or more.
If anyone can expand on this I would be very grateful.