应该这样写,但是要保证column1和column2取出来的值是唯一的,否则要加上top 1
update table1 set colum1= (select colum1 from table2 where condition1) ,
colum2= (select colum2 from table2 where condition1) 
WHERE condition2 

解决方案 »

  1.   

    不行,可用:
    update table1 set table1.colum1=table2.colum1,
    table1.colum2=table2.colum2
    from table1 join table2 on 連接條件
    WHERE condition2
      

  2.   

    分开写,insert才可以放在一起
      

  3.   

    update table1 
    set colum1 = (select colum1 from table2 where condition1) ,
    colum2 = (select colum2 from table2 where condition1) 
    WHERE condition2
    --or
    update a 
    set a.colum1 = b.colum1,
    a.colum2 = b.colum2
    from table1 a ,table2 b
    WHERE .........
      

  4.   

    再问一下从一个表里读取数据插入另外一个表,这个SQL怎么写:
    insert into table1(col1,col2) values(select col1,col2 from table2 ) where....
      

  5.   

    update table1 set colum1=b.colum1,colum2=b.colum2 
    from table1 as a,(select colum1,colum2 from table2 where condition1) as b 
    WHERE condition2
      

  6.   

    insert table1(col1,col2)
      select col1,col2 from table2 where conditions
    where conditions2
    请问这样可以吗。我用了总是不得,但语法查检又没有提示错误。
      

  7.   

    insert into table1(col1,col2)
      select col1,col2 from table2 where conditions
      

  8.   

    insert into table1(col1,col2)
      select t1.col1,t2.col2 from table1 as t1,table2 as t2 where (t1.col1=t2.col2)
    这样就可以