核心sql,通过控制检索条件,来取得不同的检索结果。有时间在详细解释
select distinct e.id,e.name,e.level,e.up_level
from crm_district a
inner join crm_district b on a.id=b.up_level or a.id=b.id
inner join crm_district c on b.id=c.up_level or b.id=c.id
inner join crm_district d on c.id=d.up_level or c.id=d.id
inner join crm_district e on d.id=e.up_level or d.id=e.id
where a.id=1