簡體   English   中英

從 table2 插入到 table1 有條件

[英]insert into table1 from table2 with condition

我有兩個表,我想在 table2 的 table1 的新列 (Orders) 之一中插入數據。 請任何幫助,下面的代碼不起作用

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

嘗試這個:

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

UPDATE Table1 SET Orders =(SELECT Orders from Table2 WHERE table1.Id = table2.Id)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM