update table1 from table2 set table1.col2 =table1.col2 where table1.col1=table2.col2

解决方案 »

  1.   

    update table1 set table1.col2 =table1.col2 from table2 where table1.col1=table2.col2
      

  2.   

    update table1 set table1.col2 = table2.col2 where exists (select 1 from table2 where table1.col1=table2.col1)
      

  3.   

    update table1 set table1.col2=table2.col2 from table left join table2 on table1.col1=table2.col1不过我看不明白你的2为什么没有值。
    col1 col2  
    1     v       
    2     
    3     e
    4     
      

  4.   

    update table1 
    set table1.col2=table2.col2 
    from table1 left join table2 on
     table1.col1=table2.col1
      

  5.   

    想知道为什么sql server中不能用外连接符号“*”
      

  6.   

    请大家比较一下,下面两种SQL语句,谁的效率更高update table1 set table1.col2 =table1.col2 from table2 where table1.col1=table2.col2update table1 set table1.col2=table2.col2 from table left join table2 on table1.col1=table2.col1
      

  7.   

    请大家比较一下,下面两种SQL语句,谁的效率更高update table1 set table1.col2 =table1.col2 from table2 where table1.col1=table2.col2update table1 set table1.col2=table2.col2 from table left join table2 on table1.col1=table2.col1update table1 set table1.col2 = table2.col2 where exists (select 1 from table2 where table1.col1=table2.col1)
      

  8.   

    update table1 set table1.col2 =table1.col2 from table2 where table1.col1=table2.col2
      

  9.   

    update table1 set col2=a.col2 from table2 a where table1.col1=a.col1
      

  10.   

    最简写法:
    update table1 set col2=a.col2 from table2 a where table1.col1=a.col1
      

  11.   

    题目改为: 
    table1:
    col1 col2  
    1            
    2
    3
    4
    table2:
    col col2
    1   v
    3   e 
    6   r
    2   y
    要求如下:
    根据tabl1.col1=tabl2.col 更新table1,使其的值如下所示.
    col1 col2  
    1     v       
    2     y
    3     e
    4     就是对的!
      

  12.   

    To -> pengdali(大力) 感谢给予的改正.
    感谢楼上所有的解决方法。