表table1
id    oldsid  newsid
1     1001    1002
2     1002     1005
3     1003     1001表table2
Sid   unitname
1001    AT01
1002    AT02
1003    AT03
1004    AT04
1005    AT05求语句实现:
id    oldsid  newsid  unitname1  unitname2
1     1001    1002     AT01             AT02
2     1002     1005    AT02             AT05
3     1003     1001    AT03             AT01用以下sql报错 “ora-03113”通信通道的文件结尾:
select t1.id, t1.oldsid ,t1.newsid,
(select  unitname from table2 where sid=t1.oldsid ) as unitname1  ,
(select  unitname from table2 where sid=t1.newsid ) as unitname2 
from table1 t1

解决方案 »

  1.   


    select t1.id, t1.oldsid ,t1.newsid,
    unitname as unitname1  ,
    unitname as unitname2 
    from table1 t1,table2 t2,table2 t3
    where sid=t2.oldsid
      and sid=t3.newsid
    ;
    改成这样呢?应该 不是你的语句问题
      

  2.   

    select t1.id, t1.oldsid ,t1.newsid,
    t2.unitname as unitname1  ,
    t3.unitname as unitname2 
    from table1 t1,table2 t2,table2 t3
    where sid=t2.oldsid
      and sid=t3.newsid
    ;
      

  3.   

    with t1 as(
    select 1 as id,1001 as oldsid,1002 as newsid from dual
    union all
    select 2,1002,1005 from dual
    union all
    select 3,1003,1001 from dual
    ),
    t2 as (
    select 1001 as Sid,'AT01' as unitname from dual
    union all
    select 1002 as Sid,'AT02' as unitname from dual
    union all
    select 1003 as Sid,'AT03' as unitname from dual
    union all
    select 1004 as Sid,'AT04' as unitname from dual
    union all
    select 1005 as Sid,'AT05' as unitname from dual
    )select t1.id,t1.oldsid,t1.newsid,(select unitname from t2 where t2.Sid=t1.oldsid) unitname1,(select unitname from t2 where t2.Sid=t1.newsid) unitname2
    from t1
      

  4.   

    应该是某个id找不到对应的name造成的
    把子查询中的unitname改为max(unitname)试试
      

  5.   

    参考
    http://blog.csdn.net/zwk626542417/article/details/39667999
    查一查是不是哪满了,写不进去了
      

  6.   

    从语句上看没问题。查看一下alert日志,应该有错误信息