以下のクエリを使用して、あるテーブルから別のテーブルにレコードをコピーすると、エラーが発生します
insert into table1 (datestamp)
select datestamp
from table2
where table1.datestamp is null
テーブル 2 の日付スタンプのレコードをテーブル 1 にコピーしたいのですが、テーブル 1 の日付スタンプが null です。
以下のクエリを使用して、あるテーブルから別のテーブルにレコードをコピーすると、エラーが発生します
insert into table1 (datestamp)
select datestamp
from table2
where table1.datestamp is null
テーブル 2 の日付スタンプのレコードをテーブル 1 にコピーしたいのですが、テーブル 1 の日付スタンプが null です。
これはあなたが意味するものですか?
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