MySQL function to return breadcrumb-like string from hierarchical structure
delimiter //
create function derp(IN myId int) returns varchar(255) begin
    select concat(t1.name, ' &gt; ', t2.name, ' &gt; ' t3.name) from a t1 join a t2 on t1.parent_id=t2.id join a t3 on t2.parent_id = t3.id where t1.id=myId;
end//


Not tested, just off the top of my head.  For reference http://dev.mysql.com/doc/refman/5.5/en/create-procedure.html