update a1 P set(col1,col2)=(select col1,col2 from a2 Q where P.col1=Q.col1)

解决方案 »

  1.   

    update a1 P set(col1,col2)=(select col1,col2 from a2 Q where P.col1=Q.col1)
    where exists (select 1 from a2 Q where P.col1=Q.col1)
      

  2.   

    update a1 p set co12=(select co12 from a2 q where q.co11=a1.col11)
      

  3.   

    to:zmgowin(隐者(龙祖宗))update a1 P set(col1,col2)=(select col1,col2 from a2 Q where P.col1=Q.col1)
    where exists (select 1 from a2 Q where P.col1=Q.col1)你后面的where条件是做什么用的?
      

  4.   

    update a1 p set col2=(select col2 from a2 q where p.col1=q.col1)
    where exists(select col1 from a2 where p.col1=q.col1)
      

  5.   

    where 条件当然有作用了,不信你试试
      

  6.   

    将where条件放到子查询里面去,才可以限制子查询返回的结果集.放在外面的where条件,是限制修改的记录条数.
      

  7.   

    奇怪了,怎么都搞不定了,请指教:表a1:
    col1   col2
    a1      1
    a2      1
    a3      1表a2:
    col1   col2
    a1      4
    a2      2
    a3      10两张表如上,我想把a2中字段col2的值小于8的更新到a1中,怎么写,调了半天了都搞不好,郁闷死了
      

  8.   

    update a1 p
    set col2 = (select q.col2 from a2 q where p.col1 = q.col1 and q.col2 < 8 )
    wehre exists (select 1 from a2 x where p.col1 = x.col1 and x.col2 < 8 )
      

  9.   

    update a1 
    set a.col2=b.col2
    from a1 a,a2 b
    where a.col1=b.col1 and b.col2<8
      

  10.   

    把a2中字段col2的值小于8的更新到a1中,我支持 lguotao() ( ) 的方法:
    update a1 
    set a.col2=b.col2
    from a1 a,a2 b
    where a.col1=b.col1 and b.col2<8
    简便,快捷,易理解!顶!顶!!