DROP FUNCTION IF EXISTS PersonName;
CREATE FUNCTION PersonName(parent_id smallint) RETURNS VARCHAR(20) DETERMINISTIC
RETURN (SELECT job_name FROM qx_people_resource WHERE id_=parent_id);
SELECT PersonName(id_) AS child, PersonName(parent_id) AS parent
FROM qx_people_resource;
参考:http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html#adjacency_list_model