注:表A的TARGETSTOCKID和SOURCESTOCKID是表B的ID的外键

解决方案 »

  1.   

    select b.name as ARGETSTOCKNAME , c.name as SOURCESTOCKNAME
    from 表A a , 表b b , 表b c 
    where a.targetstockid = b.id and a.sourcestockid = c.id
      

  2.   

    select 
        b.name targetstockname,
        c.name sourcestockname 
    from 
        tablea a,
        tableb b,
        tableb c 
    where 
            a.targetstockid=b.id 
        and a.sourcestockid=c.id
      

  3.   

    select t.name TARGETSTOCKNAME,s.name SOURCESTOCKNAME 
      from table_a d,table_b t,table_b s
      where d.targetstockid=t.id and d.sourcestockid=c.id;