SELECT area_.id, area_.name FROM ( SELECT @r AS _id, (SELECT @r := parentid FROM `hk_area` WHERE id = _id) AS parentid, @l := @l + 1 AS lvl FROM (SELECT @r := 2106, @l := 0) vars, `hk_area` h WHERE @r <> 0) area_1 JOIN `hk_area` area_ON area_1._id = area_.id ORDER BY area_1.lvl DESC