回复人: wutao411(了缘) ( ) 信誉:100 
insert into table1
select * from table2 where id in ('1','2') and date not in (select date from table1 where id in ('1','2'))

解决方案 »

  1.   

    了缘哥哥  后来小弟回去试了试  问题是 date 与 id是 联合主键  当table1 中已存在 2004-5-12    1
    的时候   table2 中的2004-5-12   2   的信息是插不进table1 表中的!~~
      

  2.   

    全部弄进去?
    delete table1
    insert into table1 select * from table2--orinsert into table1 select * from table2 a where id in ('1','2') and not exists(select 1 from table1 that id=a.id and date=a.date)
      

  3.   

    insert into table1 select * from table2 a where id in ('1','2') 
    and id not in(select id from table1 where id=a.id and date=a.date)
      

  4.   

    insert into table1
    select * from table2 a
    where id in ('1','2') 
    and not exists (select 1 from table1 
    where id=a.id
    and [date]=a.[date])