select decode(id1,1,'a',2,'b',3,'c',id1)||decode(id2,1,'a',2,'b',3,'c',id2)||decode(id3,1,'a',2,'b',3,'c',id3) from table1 更灵活的办法:用存储过程

解决方案 »

  1.   

    select translate(id1,'123','abc')||translate(id2,'123','abc')||translate(id3,'123','abc') from table1 
    和上面的一样,局限性比较大
      

  2.   

    樓上把table2的内容給寫死在SQL裏了,如果以後資料變動要改SQL語句很麻煩
    建議用下面的SQL語句,不怕Table2种資料變化。select a.name,b.name,c.name 
    from table1 M,table2 a,table2 b,table3 c 
    where M.id1=a.id(+)
    and M.id2=b.id(+)
    and M.id3=c.id(+)上面用(+)的目的是爲了防止有Table2种無對應值得問題。
    如果樓主保證table2中一定存在,那麽可以將(+)去掉