select a.lineid,a.stationid1,b.stationname,c.provinceName
from line a,station b,province c
where a.stationid1=b.stationid and b.provinceID=c.provinceID
union all
select a.lineid,a.stationid2,b.stationname,c.provinceName
from line a,station b,province c
where a.stationid2=b.stationid and b.provinceID=c.provinceID

解决方案 »

  1.   

    try:
    select a.lineid,b1.stationname,c1.provincename,b2.stationname,c2.provincename,
    from line a,station b1,station b2,province c1,province c2
    where a.stationid1=t1.stationid and a.stationid2=t2.stationid 
    and b1.provinceid=b1.provinceid and b2.provinceid=b2.provinceid ;
      

  2.   

    select stationName,provinceName
    from station b ,province c where a.lineid=lineid
    and a.stationid1=b.stationid and b.provinceID=c.provinceID
      

  3.   

    union
    select stationName,provinceName
    from station b ,province c where a.lineid=lineid
    and a.stationid2=b.stationid and b.provinceID=c.provinceID