[英]SQL statement to insert into database table not working - “Invalid column name”
[英]Invalid column name on Insert Into statement
我需要將值從一個表插入到另一個表。 但是,當我運行命令時,會收到此響應。
消息207,第16級,州1,第4行
無效的列名“ table1column”。消息207,第16級,州1,第5行
無效的列名“ othertable1column”。
這是我的代碼:
insert into table2 (column2)
select column1
from table1
where table2column = table1column
and othertable2column = othertable1column
我究竟做錯了什么?
我懷疑您確實想要更新:
update table2
set column2 = column1
from table2 join
table1
on table2.table1column = table1.table1column and
table2.andothertable2column = table1;othertable1column;
insert
插入新行。 update
更新現有行中的值。 如果您試圖將兩個表連接在一起,則可能您想要的行已經在table2
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.