This is my code, my problem is content of ParentId and Tags is always null. It's not supposed to be like this. I do not why it happens? Can somebody tell why?
CREATE PROCEDURE appendtags()
BEGIN
DECLARE done INT;
DECLARE postId_1,postId_2,parentId INT(11);
DECLARE tags VARCHAR(128);
DECLARE cur1 CURSOR FOR SELECT PostId,ParentId FROM test.t1;
DECLARE cur2 CURSOR FOR SELECT PostId,Tags FROM test.t2;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
SET done=0;
OPEN cur1;
OPEN cur2;
REPEAT
IF postId_2=parentId THEN
INSERT INTO t3 VALUES(postId_1,parentId,tags);
ELSE
FETCH cur2 INTO postId_2,tags;
END IF;
FETCH cur1 INTO postId_1,ParentId;
UNTIL done END REPEAT;
CLOSE cur1;
CLOSE cur2;
SET done=0;
END