update t2 b set b.name=(select a.name from t1 a where a.code=b.code and a.name='bbb') 呵呵
这不等效于
update t2 set name='bbb'么?

解决方案 »

  1.   

    你的update b
      set b.name=a.name
      from t1 a, t2 b
      where a.code=b.code and a.name='bbb'这句效果就是update t2 set name='bbb' 
    from t1 a, t2 b
      where a.code=b.code and a.name='bbb'
    不信你可以试试
      

  2.   

    --为了减少误会改为如下:
    --sqlserver 中的写法
    update b
      set b.name=a.name
      from t1 a, t2 b
      where a.code=b.code and a.name<>'ccc'
    ;
    --请问oracle中等效的sql语句如何写
      

  3.   

    update t2 set t2.name = (
           select t1.name 
             from t1 
            where t1.code = t2.code
                  and t1.name <> 'ccc')
    这一句在sql server与oracle都能执行.
    在sql server中,t2后不能带别名(我这里是sql server7).
      

  4.   

    suleen的答案错了,我这里执行不了,提示返回重复的行,原因应该出现在where不应在里
    面,应该在外面而且还要加一些条件。