Home > Database > Mysql Tutorial > oracle树形查询,oracle树形模糊查询

oracle树形查询,oracle树形模糊查询

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 14:57:59
Original
1543 people have browsed it

管理系统树形结构模糊查询,oracle树形查询 无 由根节点查询所以子节点 select * from mytable where 1=1 start with name like '%起始节点%' connect by prior id = pid 由子节点查询所以根节点 select * from mytable where 1=1 start with name like '%起

管理系统树形结构模糊查询,oracle树形查询
  由根节点查询所以子节点
  select * from mytable
    where 1=1
  start with name like '%起始节点%'
  connect by prior id = pid

    由子节点查询所以根节点
  select * from mytable
    where 1=1
  start with name like '%起始节点%'
  connect by prior pid = id 

     以上代码看是没有问题但经过本人验证会查询出不相关的节点,各种尝试都不能解决,只能妥协了

      select * from mytable
    where 1=1
  start with id in (select id from mytable where name like '%起始节点%')
  connect by prior pid = id 

     这样就解决了这个问题。算是绕过去了,后面有什么好的解决办法希望贴出来,谢谢。
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template