现在有一个分类表 category
字段如下:
id name
01 电器
0101 大家电
0102 生活电器
0103 厨房电器
010101 平板电视
010102 电冰箱
010103 洗衣机
给出一个id
如何一条sql 查询出所有分类的全路径如
010103
返回 电器-->大家电-->洗衣机
------解决思路----------------------
select id,name,sys_connect_by_path(name,'-->')
from category
start with length(id)=2
connect by prior id=substr(id,1,length(id)-2)