精易论坛

标题: oracle树形结构相关查询 [打印本页]

作者: ㄣ负二代    时间: 2013-1-24 17:34
标题: oracle树形结构相关查询
 查询最顶层元素  select * from basic_type t WHERE NOT exists(select 'x' from basic_type t1,
  basic_type t2 where t1.id=t2.parentid and t1.id= t.parentid)
  查询id为'asdfas'的属于顶层ID为4的第几级
  select * from (select LEVEL,id,parentid,name from basic_type START WITH id='4'
  CONNECT BY PRIOR id=parentid) where id= 'asdfas'

作者: 宇智波·佐助    时间: 2013-2-1 09:06
又是 oracle   
作者: 误入兰若寺    时间: 2024-10-18 19:45
数据库里面怎么放?




欢迎光临 精易论坛 (https://125.confly.eu.org/) Powered by Discuz! X3.4