
2、树形结构的实现其实很简单的,建议你看下ztree的官方api,你只需要按照数据结构递归查询出父子节点的数据即可
3、mybatis是java中实现的方式了,至于你想怎么优化,最后都是递归查询父子节点的数据
select id,name,
pid
from(select * from products
order by pid, id) products_sorted,
(select @pv := '1') initialisation
where find_in_set(pid, @pv)
and length(@pv := concat(@pv, ',', id))
select t1.name,t2.name,t3.name,t4.namefrom tb as t1
left join tb as t2 on t2.pid=t1.id and t2.pid=1
left join tb as t3 on t3.pid=t2.id and t3.pid=2
left join tb as t4 on t4.pid=t3.id and t4.pid=3
where pid=0
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)