树的查询

1,查所有的子节点 select  *  from wz_tree   start with id = 1 connect by prior id = pid;
2,查所有的父节点  select  *  from wz_tree   start with id = 256 connect by prior pid = id;
3,查分类的路径, 用逗号连接:select  sys_connect_by_path(mc, ',')   from wz_tree   start with id = 1 connect by prior id = pid; http://www.itpub.net/838127.html讲的很详细
4,查某个表的字段名:
select max(substr(SYS_CONNECT_BY_PATH(COLUMN_NAME, ','), 2)) col
  from (select COLUMN_NAME, column_id
          from user_tab_columns
         where table_name = '&TEST')--&为plsqldeveloper里的字符串占位符,执行时会弹出对话框让你填值
 start with column_id = 1
connect by column_id = rownum;

5,select  *  from wz_tree where mc like '%五金'  start with id = 1 connect by prior id = pid;
和select  *  from wz_tree start with id = 1 connect by prior id = pid and mc like '%五金' 
二者的查询结果不一样



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值