我知道如何使用join
更新表格,如:
update t1
set t1.id=t2.id2
from #table1 t1
inner join #table2 t2
on t1.id=t2.id2
但我不知道插入。
如何从#table1(id,name)
插入数据
使用table2 (id,name)
到#join
?
答案 0 :(得分:1)
INSERT INTO table2(id, name)
SELECT t1.id, t1.name FROM table1 t1
INNER JOIN table2 t2
ON t1.id = t2.id;
答案 1 :(得分:1)
insert into #table2(id,name)
select #table1 t1.id,t1.name
from #table1 t1
inner join #table2 t2
on t1.id=t2.id2
答案 2 :(得分:0)
可能是你看起来像这样:
insert into #table2 (id,name)
select #table1 t1.id,t1.name
from #table1 t1
inner join #table2 t2
on t1.id=t2.id2