Jeg prøvede bare med loop struktur i Mysql og fik succes. Sender kun for at dele--
CREATE PROCEDURE `root_connect`(IN init char(1),OUT str char(15))
BEGIN
set @startChar:=(select connector from tableName where root = init);
set @endloop := "no";
set @fullchar:= @startChar;
set @newchar:= "";
if (@startChar !="-" OR @startChar =null) then
WHILE (@endloop = "no") DO
set @newchar :=(select connector from tableName where root = @startChar);
if(@newchar = '-') THEN
set @endloop := "yes";
else
set @fullchar:= concat(@fullchar,"-",@newchar);
end if;
set @startChar := @newchar;
END WHILE;
end if;
select @fullchar;
END