update gc_item_property set gc_item_property.item_gpdate=
(select gc_basestation_info.gpdate
from gc_item_property,gc_basestation_info
where gc_item_property.basestationname=gc_basestation_info.basestationname
and gc_basestation_info.gpdate like '9%') ;=号后面的select语句不能返回多行,否则出错。

解决方案 »

  1.   

    to snowy_howe(天下有雪) :这样不行啊!!我需要的=号后面的select语句一定是返回多行的,我现在需要把A表中的每条记录的gpdate值赋给B表中的item_gpdate,这两个表中的数据是对应的,所以返回多行是必然的了!
    有没有其他办法?大家帮忙啊,急啊!!
      

  2.   

    up !up !up !up !up !up !up !up !
      

  3.   

    update gc_item_property set gc_item_property.item_gpdate=
    (select gc_basestation_info.gpdate
    from gc_item_property,gc_basestation_info
    where gc_item_property.basestationname in (slect basestationname from gc_basestation_info where gc_basestation_info.gpdate like '9%') ;
      

  4.   

    to lemon223(oracle) :还是不行,执行你给的sql语句出现如下错误:
    ORA-01652: 无法通过256(在表空间TEMP中)扩展temp段
      

  5.   

    你的语句应该可以啊,报什么错啊? 你试试把它改为:
    update gc_item_property set a.item_gpdate=b.gpdate
    from gc_item_property a,gc_basestation_info b
    where gc_item_property.basestationname=gc_basestation_info.basestationname
    and gc_basestation_info.gpdate like '9%' ;
      

  6.   

    表别名没有改完,你自己改啊,另外,你的表是在oracle的同一个用户下吧,注意一下是不是权限问题。
      

  7.   

    To:to snowy_howe(天下有雪) :这样不行啊!!我需要的=号后面的select语句一定是返回多行的,我现在需要把A表中的每条记录的gpdate值赋给B表中的item_gpdate,这两个表中的数据是对应的,所以返回多行是必然的了!
    有没有其他办法?大家帮忙啊,急啊!!--------------------------------------------------------------------------
    将多行值赋给一个字段,这样更新在逻辑上是不是有点问题???
    或者说没有理解楼主的意思!!!楼主再详细描述一下需求,
    如果A表与B表的数据是一一对应的话,snowy_howe(天下有雪)就符合你的
    要求,如果需要的A表中gpdate值在B表中却可以查出多个值,这样更新会
    失败,在逻辑上也好像有问题。
      

  8.   

    不是要把多行值赋给一个字段,我的需求如下:
    A表中是一个基站信息表:
    基站编号   基站名称   工期
       1      (基站名称) 9A
    ......    B表是一个项目属性表:
    项目编码   基站名称   工期
    LS200401   (对应A表) (需要从A表中对应基站名称来更新的字段)总结:在B表中以前没有“工期”这个字段,由于系统升级的需要,现在要加一个工期字段,由于B表中已经有近万条数据,因此需要通过一个预先处理来填充新加的“工期”这个字段的值,便于程序处理。
    现在只能通过这两个表中的基站名称对应相等的就把A表中的“工期”更新给B表中对应的“工期”。不知上面的描述大家明白我的意思没有??
      

  9.   

    to  zrb007(彬彬) :我的语句在sqlserver中执行正常,可是在oracle中执行出现如下错误:
    ORA-00933: SQL命令未正确结束
      

  10.   

    update gc_item_property a
    set a.item_gpdate (select b.gpdate from gc_basestation_info b 
    where a.basestationname = b.basestationname and b.gpdate like '9%' );
    应该是可以的.
      

  11.   

    SQL>update gc_item_property a
    SQL>set a.item_gpdate=(select b.gpdate from gc_basestation_info b
    SQL>where a.basestationname=b.basestationname
    SQL>and b.gpdate like '9%');
      

  12.   

    谢谢 zgh2003(世纪飞扬) 的热心解答,问题终于解决!!小弟就此结贴,zgh2003(世纪飞扬) 将重新开贴给分!!