select id,path from table
where path<>'000200010001'
and path like '0002%'

解决方案 »

  1.   

    呵呵,刚才没有表达清楚可能
    id   path
    01   0001
    02   00010001
    03   00010002
    04   0002
    05   00020001
    06   00020002
    07   000200010001
    08   000200010002
    09   0002000100020001
      

  2.   

    通过Path找到所以其上级的id,根级的path是4位
    必如已知path=000200010001过滤完后应该是id   path
    ================================
    04   0002
    06   00020001
      

  3.   

    select it,path from t4 where substr(path,1,4)=substr('000200010001',1,4) and decode(substr(path,5,4),null,substr('000200010001',5,4),substr(path,5,4))=substr('000200010001',5,4) and substr(path,9,4) is null
      

  4.   

    select * from table where instr('000200010001',path)>0
      

  5.   

    错了,应该是 select * from table where instr('000200010001',path)=1
      

  6.   

    楼上的写的不错,不过声明:path最长可以是80位,也就是可以分20级
      

  7.   

    sunnyrain(旭雨)
    =============================select * from table where instr('000200010001',path)=1
    这条语句好,精炼