无限极分内 自联查询

select gtext,ftext,stext from (select a.id as gid,a.pid as gpid, a.text as gtext,b.id as fid,b.pid as fpid,b.text as ftext,c.id as sid,c.pid as spid,c.text as stext
from ag_base_area a join ag_base_area b on a.id=b.pid
left join ag_base_area c on b.id = c.pid order by stext) n
where fpid<1000 order by gtext

原文地址:https://www.cnblogs.com/cw828/p/11934443.html