我现在有两张表,table1,table2,关联的字段是id现在是想把table2中的字段ggg更新到table1中的ggg中请问,要怎么写update table1 set a.ggg=b.ggg from table1 a,table2 b where a.ccid=b.ccid;我这样写有什么错吗 ?请指教

解决方案 »

  1.   

    有错,你这是MS SQL的写法,ORACLE不行的
      

  2.   

    update table1  a set a.ggg= (select b.ggg from table a,table b where a.ccid=b.ccid)
     where a.ccid=(select b.ccid from table b);
      

  3.   

    update table1 set a.ggg=(select b.ggg from table2 b where a.ccid=b.ccid);
      

  4.   

    update table1 a set a.ggg=(select b.ggg from table2 b where a.ccid=b.ccid);
      

  5.   

    hebo2005()为什么在后面还要加一句where a.ccid=(select b.ccid from table b);不是非常理解。本人觉的update table1 set a.ggg=(select b.ggg from table2 b where a.ccid=b.ccid);就可以了啊。
      

  6.   

    hebo的重复了;
    直接update table1 set a.ggg=(select b.ggg from table2 b where 
    a.ccid=b.ccid);就可以了。
      

  7.   

    update table1 a set a.ggg=(select b.ggg from table2 b where a.ccid=b.ccid);
      

  8.   

    要加where a.ccid=(select b.ccid from table b)这个条件,否则你会把A表中的GGG赋为同一个值的.