drop procedure if exist mypro;
delimiter $$
creat procedure mypro($stuID int)
begin
set @friends='';
select BestFriendID into @BestFriendID from friends where stuID=$stuID;
while(@BestFriendID<>'') DO
select @friends:=concat(@friends,' ',stuName),@BestFriendID:=BestFriendID from friends where stuID=@BestFriendID;
end while;
select @friends;
end $$
delimiter ;
call mypro();