select a.nm
from a
where a.op_id=(select a.op_id
               from a,b
               where a.op_id=b.u_id and b.or_id=(select b.or_id
                                                 from b,c
                                                 where b.or_id=c.re_id and c.re_id='000022'))

解决方案 »

  1.   

    select select a.nm
    from a,b,c
    where a.op_id=b.u_id 
    and   b.or_id=c.re_id 
    and   c.re_id='000022'
      

  2.   

    select a.nm
    from a,b
    where a.op_id=b.u_id and b.or_id='000022'
      

  3.   


    select a.nm from a,b,c
    where a.op_id=b.u_id and  b.or_id=c.re_id and  c.re_id='000022'--or
    select a.nm from a,b
    where a.op_id=b.u_id and  b.or_id='000022'
      

  4.   

    select a.nm,b.nm from a,b
    where a.ap_id=b.u_id and a.op_id=b.u_id and  b.or_id='000022'前一个条件a.ap_id=b.u_id 是用来查找b.nm的
    a.op_id=b.u_id and  b.or_id='000022'这是用来找a.nm的
    这样怎么改,我写的那个,sql是错的
    因为要从2张表里读出数据做一个列表
      

  5.   

    a表
    nm     订单号
    ap_id  分派人id     与b表u_id对应
    op_id  处理人id     与b表u_id对应b表
    nm     人员名称
    u_id   人员id 
    o_id   机构id
    结果列表
    a.nm     b.nm
    订单号    分派人
    查询传进机构id 000022
    查找出处理人是属于此机构的订单
    并且查找出此订单的分派人名称
      

  6.   


    select a.nm,b.nm from
    (select a.nm,a.ap_id from a,b where a.op_id = b.u_id and o_id = 1) a,b 
    where a.ap_id = b.u_id;
      

  7.   

    id的值写的有问题,改成000022试试。
    select a.nm,b.nm from
    (select a.nm,a.ap_id from a,b where a.op_id = b.u_id and o_id = '000022') a,b 
    where a.ap_id = b.u_id;
      

  8.   

    select a.nm,t2.nm
    from a,b t1,b t2
    where a.op_id=t1.u_id
      and t1.o_id='xxxx'
      and a.ap_id=t2.u_id