用sql语句从数据库中读取树形结构,仅适用于有两级的目录,select * from tablename order by case when parentid=0 then id*10000 else parentid*10000+id end;
其中parentid是父id,详细地址:http://www.cnblogs.com/haozhenjie819/p/3901416.html