很高兴回答你的问题根据你的需求,写的sql如下:selectid,lpad(name,length(name)+(level*10),'')fromtable_namewhere1=1startwithfidisnullconnectbypriorid=fid;根据你的问题补充:selectidfromtable_namewhereidnotin(selectidfromtable_namewhere1=1startwithid=1connectbypriorid=fid);上边这个sql就查询出来当id=1的时候,能作为它上级的id,希望对你有所帮助。
@god147
顶0
加入收藏
相关问答推荐