我有2个表,2个表里面有名称相同的字段,也就是外键select * from(
select * from loginuser a, orgtree b ***后面条件略去
) where rownum<=1总是报未明确指定列,我该怎么写啊

解决方案 »

  1.   

    列名不能重复 
    select * from(
    select col1,col2,col3 from loginuser a, orgtree b ***后面条件略去
    ) where rownum<=1
      

  2.   

    select * from(
    select * from loginuser a, orgtree b ***后面条件略去
    ) T where rownum<=1
      

  3.   

    select * from loginuser a, orgtree b 这个里面的*号要写清楚列名
      

  4.   

    select * from(
    select * from loginuser a, orgtree b ***后面条件略去
    )T where rownum<=1
      

  5.   

    select * from loginuser a, orgtree b ***后面条件略去 这里面有名称相同的列
      

  6.   

    select * from(
    select * from loginuser a, orgtree b ***后面条件略去
    ) as t where rownum<=1别名别忘记了
      

  7.   

    我把完整的贴出来吧public SignatureManagePO getImageBySheetnumber(String sheetnmbr, int userid) throws SQLException{
    SignatureManagePO po = new SignatureManagePO();
    String sql = "select * from(" +
    "select * from signaturemanage a, sheetwkflowstatus b, loginuser c where b.sheetnmbr='" + sheetnmbr + "' and b.userid = "+ userid +" and b.userid = c.userid and b.exittimestamp is not null and c.userid = a.userid and a.disabled = 0 order by b.swsid) where rownum <= 1";

    Result result = super.retrieve(sql, po);
    return (SignatureManagePO) result.getBeans();
    }怎么改?
      

  8.   

    是不是你子查询里头 几张表有一样名字的字段 你都用的* 不行啊 要制定 明确 最后应该是t.rownum<=1
    ?
      

  9.   

    select from signaturemanage a, sheetwkflowstatus b, loginuser c where b.sheetnmbr='" + sheetnmbr + "' and b.userid = "+ userid +" and b.userid = c.userid and b.exittimestamp is not null and c.userid = a.userid and a.disabled = 0 order by b.swsid) t where rownum <= 1";吧当中的*替换成你需要的列,如果2个表中的列名相同需要重新命名如 select b.userid as buserid,c.userid as cuserid from sheetwkflowstatus b,loginuser c
      

  10.   


    select * 
    from(
    select * --列名应该有重复
    from signaturemanage a
     ,sheetwkflowstatus b
     ,loginuser c 
    where b.sheetnmbr='ddddd' 
      and b.userid = eeeee 
      and b.userid = c.userid 
      and b.exittimestamp is not null 
      and c.userid = a.userid 
      and a.disabled = 0 
    order by b.swsid
    ) a  --少了别名
    where rownum <= 1;--rounum列可能不存在
      

  11.   

    select * from (select a.*,b.* from loginuser a,orgtree b)...
    where rowNum<=1 改成这样试一下