update tableA set col1=
(select col1 from tableA,tableB where tableA.col2=tableB.col2)
where exist(select 1 from tableA,tableB where tableA.col2=tableB.col2)

解决方案 »

  1.   

    这样写就对了
    update tableA set tableA.col1=
    (select tableB.col1 from tableB where tableA.col2=tableB.col2)
    where exist(select 1 from tableB where tableA.col2=tableB.col2)
      

  2.   

    忘了交代的是:select  tableA.col1  from  tableA,tableB  where  tableA.col2=tableB.col2 存在多条记录。如果是仅存在一条的化
    update  tableA  set  col1=  
    (select  tableA.col1  from  tableA,tableB  where  tableA.col2=tableB.col2)  
    where  exists(select  1  from  tableA,tableB  where  tableA.col2=tableB.col2) 应该没有问题.
      

  3.   

    加一个max或min ,再试试
    update tableA set tableA.col1=
    (  select max(tableB.col1) from tableB 
            where tableA.col2=tableB.col2 
            group by tableB.col1  )
    where exist(select 1 from tableB where tableA.col2=tableB.col2)
      

  4.   

    无论是加max还是min,还有distinct都不行,返回“ORA-01427: 单行子查询返回多于一个行”的错误。唉不知该怎么玩它!!!!