我有一个名为empty
的表,如下所示,只有paperkey值,其他一切都是空的。
author | year | conference | paperkey
1234
我还有一个名为base
的表,如下所示:
author | year | conference | paperkey
Andrew 1999 KDD 1234
我想将表base
中检索到的值插入表empty
。
我试着按如下方式查询但是没有用。如何修改此查询以获得正确的结果?
insert into empty (author, year, conference)
select T1.author, T1.year, T1.conference
from base as T1
inner join empty as T2 on T1.paperkey=T2.paperkey;
答案 0 :(得分:1)
我认为您希望根据empty
paperkey
update empty e
join base b on b.paperkey = e.paperkey
set
e.author = b.author,
e.year = b.year,
e.conference = b.conference
答案 1 :(得分:1)
您想要更新现有记录,而不是插入新记录。
update empty T2
join base T1 on T1.paperkey = T2.paperkey
set T2.author = T1.author,
T2.year = T1.year,
T2.conference = T1.conference