select id,
SUBSTR(id,1,4) 
select table
我想将SUBSTR(id,1,4) 翻译成name,怎么弄===================
select 
id,
SUBSTR(id,1,4)  as la ,
(select name from table where id=la ) as name_fy
select table
这样写不对

解决方案 »

  1.   

    知道了,直接这样写
    select 
    id, (select name from table where id=SUBSTR(id,1,4)as name_fy 
    select table 
      

  2.   


    最后是from table 吧
      

  3.   

    还是不行,可以执行,但没结果
    select 
    id, (select name from table where id=SUBSTR(id,1,4)as name_fy 
    from table --------------
    name_fy  列没内容
      

  4.   

    select 
    id, 
    (select name from table t1 where t1.id=SUBSTR(t.id,1,4) ) as name_fy 
    from table t
    这样能执行,但数据多的话,效率可能比较差,用表关联可能好些
      

  5.   

    问题已解决。
    是没去空格,加上trim就好了。
      

  6.   

    select a.id,decode(a.la,a.id,a.name,''),la from (select id,substr(id,1,4) as la from table) a 
      

  7.   

    不明白table 
    id     name
    ------------
    00010  name1
    00011  name2
    00012  name3你想要什么结果