update table1 set name='newvalue' where id = (select id from table2 where address='address');

解决方案 »

  1.   

    update table1 b set name=(select a.address from table2 a where a.id=b.id);
      

  2.   

    update table1 set table1.name='newvalue'
    where exists 
    (select 1 from table2 where table1.id=table2.id);
      

  3.   

    yxxx(小孬) 如果想该多个字段时,好象有问题? 是不
      

  4.   

    楼主,table1的name字段用table2里的什么来更新呢?
      

  5.   

    tab1el(id,name)
    table2(id,address)
    table1 的id 和table2的id之相同。
    我想通过与table2的关联 更新table1 的name值,请问该怎么写update 语句?
    ------------------------------------------------------------------
    你的意思是不是这样的:
    update table1 a set name='aaa' where id=(select id from table2 b where a.id=b.id and b.address='xxx'); 
    ------------------------------------------------------------------