Oracle递归操作

需求:找出代理商中没有挂商家的代理商

简单SQL如下:

select *
  from t_proxy tp
 where tp.id not in
       (SELECT tp.id as p_id
          FROM t_proxy tp
         start with tp.id in (select distinct tm.proxy_id
                                from t_merchant tm
                               where tm.proxy_id is not null)
        connect by prior tp.parent_id = tp.id)

 

posted @ 2017-04-27 10:53  一心行走  阅读(465)  评论(0编辑  收藏  举报