insert into table1 
select * from table2 
where id not in (select id from table1)

解决方案 »

  1.   

    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)
      

  2.   

    sorry, please ignore my reply
      

  3.   

    insert into table1 select * from table2 where id not in (select id from table1)
      

  4.   

    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.主键)
      

  5.   

    insert into table1 
    select * from table2 
    where keyField not in (select keyField from table1)
      

  6.   

    没有keyfield,只有聚集索引。
      

  7.   

    那你这聚集索引一定是Unique的,否则不会提示重复键insert into table1 
    select * from table2 
    where clustered_column not in (select clustered_column from table1)
      

  8.   

    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)
      

  9.   

    insert into table1 
    select * from table2 
    where 聚集索引的列 not in (select 对应聚集索引的列 from table1)