2016-04-28 88 views
0

表2表1我有两个表,我想在表1从表2的新列(订单)的一个插入数据。任何帮助请,下面的代码无法正常工作INSERT INTO从状态

Insert into Table1 (Orders) 
    Select (orders) from table2, 
    Where table1.id=table2.id 
+0

难道你不希望'update'表1中的现有行? – jarlh

+0

我在表1中有新的“订单”列。我想用table2中的vales填充整个列。 – Ramaq

+0

当你开始时,table1是否为空?您是否想为table2中的这些值在table1中插入新行?或者你想修改table1中的现有行吗? 5 coulmn的 – jarlh

回答

0

试试这个:

update t1 
set t1.orders=t2.orders 
from Table1 t1 
inner join table2 t2 
on t1.id=t2.id