判断截串sql 以及 树递归查询函数

网址如果包含http://www则截掉 不包含www则 截掉 http://
select decode(INSTR(t.home_web_url, 'www', 1, 1),0,substr(t.home_web_url,8,length(t.home_web_url)-8),substr(t.home_web_url,12,length(t.home_web_url)-12))
from ipms_website_now t

instr:查找字符串出现位置  instr(a,b,c,d) 表示在 a从c开始第d次b出现的位置 c,d为可选默认1

父取子
select *
  from ipms_subject t
connect by prior t.id = t.parent_id
start with t.id = "?" //父id

子取父
select *
  from ipms_subject t
connect by prior t.parent_id = t.id
start with t.id = "?" //子孙id

猜你喜欢

转载自yjkun.iteye.com/blog/1528569