递归层级查询:start with connect by prior 以部门表作为解析 表结构:dept{id:'主键',name:'部门名称',parent_id:'父亲id'} select * from dept start with id=1 connect by prior id= parent_idorder siblings by id 分两部分理解: 第一步找出一条数据作为基础:select * from dept start with id =? 第二步prior放在左边还是
对象属性 public class ResList { public int ID { get; set; } public List<ResList> Child { get; set; } = null; public int Parent { get; set; } public int Rank { get; set; } } 数据就是那种有父级ID的那种 List<ResList> reslist = new List<ResList>();//新的数据
每个地区递归层级可能不一致,数据表(table)存放最小层级地区 area --地区层级表 id name f_id leve 1 中国 0 1 2 湖北 1 2 3 武汉 2 3 ... --测试数据 with area(id,"name",f_id,leve) as ( ,, union all ,, union all ,, union all ,, union all ,, union all ,, union all ,, union all ,, union all ,,