在一个表中有两个字段cldm1,cldm2,cldm1为主键,我现在要取出cldm2插入cldm1,但是cldm2中的值,有可能cldm1中有,请问这个怎么写一条语句来完成.

解决方案 »

  1.   

    试试这个语句:
    insert table1(你的表名) (cldm1)
    select cldm2 from table1 where cldm2 not in (select cldm1 from table1)
      

  2.   

    insert into table_name(cldm1) select cldm2 from table_name where 
    cldm2 not in (select cldm1 from table1)
      

  3.   

    insert table2(cldm1) select cldm2 from table2 where cldm2 not in (select cldm1 from table2)
      

  4.   

    insert into table select cldm2 from table where cldm2 not in (select cldm1 from table)
    看看這樣可不可以