sql 一个表中数据 插入另一个表中 如果没有

2025-03-23 13:46:54
推荐回答(1个)
回答1:

表1
create table table1
(
id int not null,
name varchar(50)
)
create table table2
(
id int not null,
name varchar(50)
)
insert into table1
select id,name from table1
where not exists(select 1 from table2 where table1.id = table2.id)