0

以下のクエリを使用して、あるテーブルから別のテーブルにレコードをコピーすると、エラーが発生します

insert into table1 (datestamp)
select datestamp
from table2
where table1.datestamp is null

テーブル 2 の日付スタンプのレコードをテーブル 1 にコピーしたいのですが、テーブル 1 の日付スタンプが null です。

4

2 に答える 2

1

これはあなたが意味するものですか?

insert into table1 (datestamp)
select datestamp
from table2
where table2.datestamp is null

where節でtable1 日付スタンプを参照していますが、これは許可されていません。

おそらく、あなたは本当にupdate. その場合、2 つのテーブルをリンクする方法が必要です。

update t1
    set datestamp = t2.datestamp
from table1 t1 join
     table2 t2
     on t1.id = t2.id
where t1.datestamp is null
于 2013-04-16T15:46:43.977 に答える