where is the 重复键, from table2?say you have a 键id, consider to do something likeinsert into table1 select * from table2 where table2.id not in (select id from table1)
sorry, please ignore my reply
insert into table1 select * from table2 where id not in (select id from table1)
insert into table1 select * from table2 where 主键 not in (select 主键 from table1)或:insert into table1 select * from table2 where not exists (select 1 from table1 where 主键=table2.主键)
insert into table1 select * from table2 where keyField not in (select keyField from table1)
没有keyfield,只有聚集索引。
那你这聚集索引一定是Unique的,否则不会提示重复键insert into table1 select * from table2 where clustered_column not in (select clustered_column from table1)
insert into table1 select * from table2 where not exists (select 1 from table1 where 主键=table2.主键) OR:insert into table1 select * from table2 where 主键 not in (select 主键 from table1)
insert into table1 select * from table2 where 聚集索引的列 not in (select 对应聚集索引的列 from table1)
select * from table2
where keyField not in (select keyField from table1)
select * from table2
where clustered_column not in (select clustered_column from table1)
OR:insert into table1 select * from table2 where 主键 not in (select 主键 from table1)
select * from table2
where 聚集索引的列 not in (select 对应聚集索引的列 from table1)