2016-04-28 44 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