sql心得

sql经验

1.树

select 2009 + (level - 1) from dual connect by level <= 12

 

2.递归

找小弟
 select  *
from   t_sys_org   start   with    orgid in (select  orgid from   t_sys_org   where   name ='广州技术开发服务中心')
  connect   by   prior   orgid=orgpid


找大哥
select  *
from   t_sys_org   start   with   name ='广州技术开发服务中心'
  connect   by   prior   orgpid=orgid  and orgpid = '9999999999999999999'