dividing a mysql column with mutliple values. I'm not sure how to show

try something like this and then consult the TempBob table
Better yet, build it in a view

Note: myProc does not compile – I have not done procedures for years, I'm sure the error will be obvious to @xbat, who is doing this all the time





CREATE TABLE IF THERE DOES NOT EXIST `tp` (
`id` int (11) without sign NOT NULL,
`selected_y` varchar (200) NOT NULL,
`selected_m` varchar (200) NOT NULL,
`everything` text,
PRIMARY KEY (`id`)
) CHARLET DEFAULT = utf8;
INSERT IN `TP` (` id`, `selected_y`,` selected_m`, `all`) VALUES
(& # 39 ;, & # 39 ;, & # 39; & # 39 ;, & # 39 ;, & & # 39 ;, & # 39; add to bobTextString (1A) & uro; add to bobTextString (1b) & uro; add to bobbobTextString (1c) & uro; add to bobTextString (1d) & uro; & # 39;),
(& # 39 ;, & # 39; & # 39; YB & # 39 ;, & # 39; MB & # 39 ;, add to bobTextString (2A) & uro; add to bobTextString (2b) & uro; add to bobTextString (2c) & uro; & # 39;),
(& # 39 ;, & # 39; YC & # 39 ;, & # 39 ;, & # 39 ;, & # 39; add to bobTextString (3A) & uro; add to bobTextString (3b) & uro; add to bobTextString (3c) & uro; & # 39;),
(& # 39 ;, & # 39; YD & # 39 ;, & # 39 ;, & # 39 ;, add to bobTextString (4A) & uro; add to bobTextString (4b) & uro; add to bobTextString (4c) & uro; & # 39;);

CREATE TABLE IF THERE DOES NOT EXIST TempBob (tp_id int (11), str varchar (255));

CREATE FUNCTION SPLIT_STRING (str VARCHAR (255)
, delim1 VARCHAR (25)
, delim2 VARCHAR (25)
, post INT)
VARCHAR RETURNS (255)
RETURN replace (REPLACE (SUBSTRING (SUBSTRING_INDEX (str, delim1, pos + 1),
LENGTH (SUBSTRING_INDEX (str, delim2, pos-1)) + 1),
delim1, & # 39; & # 39;), delim2, & # 39; & # 39;);

CREATE FUNCTION count_str (haystack TEXT, needle VARCHAR (32))
DETERMINISTIC INTEGRAL RETURN
ROUND RETURN ((CHAR_LENGTH (haystack) - CHAR_LENGTH (REPLACE (haystack, needle, ""))) / CHAR_LENGTH (needle));


CREATE PROCEDURE myProc () MODIFY SQL DATA
START

DECLARE done INT DEFAULT 0;
DECLARE the INT counter;
DECLARE loop_counter INT;

DECLARE tp_id INT;
DECLARE tp_all varchar (255);

DECLARE CURSOR tpcursor TO SELECT `id`,` all` FROM `tp`;
DECLARE THE CONTINUOUS MANIPULATOR FOR THE UNCONNECTED SET = 1;

OPEN tpcursor;

bob_loop: LOOP

FETCH tpcursor IN tp_id, tp_all;

IF done = 1 THEN / * No more rows * /
LEAVE bob_loop;
IT WILL END YES;

set counter = count_str (tp_all, & # 39; add to bob & # 39;);
set loop_counter = 1;

WHILE loop_counter <= counter DO
Insert in TempBob
(tp_id, SPLIT_STRING (tp_all, & # 39; add to bob & # 39 ;, & # 39; & uro; & # 39;, loop_counter));
SET loop_counter = loop_counter + 1;
Finish while

END LOOP bob_loop;
CLOSURE tpcursor;

FINISH;

call myProc ();

Code (marked):