A表:
org_id    org_name   p_id
B表:
org_id          user_id
C表:
user_id     user_name
D表:
user_id      user_pic    state分别根据user_name,org_name, state,三个字段查找user_name,user_pic,org_name结果集

解决方案 »

  1.   

    select c.user_name,d.user_pic,a.org_name  from  A a ,B b,C c,D d where a.org_id =b.org_id and b.user_id =c.user_id and c.user_id = d.user_id and c.user_name =? and a.org_name = ?
    and d.state =?试试看
      

  2.   

    不好意思,可能是我之前没说明白题意。
    分别根据user_name,org_name, state,也就是三个SQL语句1.根据user_name查询user_name,user_pic,org_name结果集
    2.根据org_name查询user_name,user_pic,org_name结果集
    3.根据state查询user_name,user_pic,org_name结果集
      

  3.   

    呵呵,原来这样就行了啊,我一直在考虑start wiht, CONNECT BY PRIOR,原来现在加了个中间表,容易多了,谢谢指导了
      

  4.   

    哥们,貌似有问题啊。根据org_name,查询不到子节点的值···
      

  5.   

    A表:
    org_id    org_name   p_id
    1            a        0
    2            a1       1
    3            a2       1这样,查找org_name为a,要把下面子节点(a1,a2)的都展示出来
      

  6.   

    select c.user_name,d.user_pic,a.org_name from A a ,B b,C c,D d where a.org_id =b.org_id and b.user_id =c.user_id and c.user_id = d.user_id and b.user_id = d.user_id
    and c.user_name =? and a.org_name = ?
    and d.state =?
    这个你试试看
      

  7.   

    select c.user_name,d.user_pic,a.org_name from A a ,B b,C c,D d where a.org_id =b.org_id and b.user_id =c.user_id and c.user_id = d.user_id and  and a.org_name like ‘%a%’
      

  8.   

    oracle树形结构查询可以用
    CONNECT BY PRIOR
    START WITH语法