表table1与表table2都有个字段NUM,例如 表1的num字段:a1至-a200(共200个记录) 表2的num字段:a2,a3,a7...a101(不规则的70个记录),我现在想要是表1与表2对比扣除相同的记录值(表1还有130个与表2不同的记录)如何做到,最好有例子,谢谢.....

解决方案 »

  1.   

    select * from table1 where num not in (select num from table2)
      

  2.   

    如果只是想把不同的记录筛选出,可以用下面的语句
    'select 表1.Num from 表1 where 表1.Num not in ('select 表2.Num from 表2)'
      

  3.   


    delete from 表1 a where exists (select 1 from 表2 b where a.Num = b.Num)
      

  4.   

    select * from t_a
    where not exists(select * from t_b where t_a.num=t_b.num)
    order by num
    /
      

  5.   


    select a.* from 表1 a where not exists (select 1 from 表2 b where a.Num = b.Num)
      

  6.   

    select a.*,b.* from a,b where a.num<>b.num