select a.tport,b.portname,a.fport,c.portname
from boatapply a , vcode b, vcode c 
where a.tport = b.portcode
and a.fport = b.portcode

解决方案 »

  1.   

    select a.tport,b.portname,a.fport,c.portname
    from boatapply a , vcode b, vcode c 
    where a.tport = b.portcode
    and a.fport = c.portcode
    楼上的写错了最后一个where clause
      

  2.   

    这样也行:
    select (select portname from vcode a,boatapply b where a.portcode=b.tport) portname1,(select portname from vcode a,boatapply b where a.portcode=b.fport) portname2 from dual;
      

  3.   

    现在出现:
    portcode在vcode中不唯一,
    vcode+flag(一个字段)才是主键
    查询的结果:
    重复的记录
      

  4.   

    那你在WHERE后面把flag字段加上就行了呀.