insert into T
select * from XX where not exists(select 1 from T where T.主鍵=XX.主鍵)

解决方案 »

  1.   

    --2insert into T
    select XX.* from XX
    left join T
    on XX.主鍵=T.主鍵
    where T.主鍵 is null
      

  2.   

    insert into 插入表(a,b,c.....)
    select * from 来源表 t where not exists(
    select * from 来源表 where a=t.a
    )
      

  3.   


    insert into 插入表(a,b,c)
    select a,b,c from 来源表 t where not exists(
    select * from 来源表 where a=t.a
    )
      

  4.   

    插入后再删除可否?
    delete from tb where _id not in (select min(_id) from tb group by c1+c2+c3)