有两个表A,B,A的字段为a,b,c,B的字段a,b,d,主键为a和b,
1.查询A,B中a和b都相同的数据
2.将A中a,b不同的插入B

解决方案 »

  1.   


    --1、
    select * from a where exists(select 1 from b where a.a=a and a.b=b)--2、
    insert into b select * from a 
    where not exists(select 1 from b where a.a=a and a.b=b)
      

  2.   

    TO:背着灵魂漫步   select 1是什么意思啊
      

  3.   

    1\
    select * from A,B wher A.a=B.b2\
    insert into B (select * from A where A.a<>B.b)
      

  4.   

    sorry
    上面的 1\  的 where 掉了个 e你试试看,是不是你要的效果
      

  5.   

    TO:zpcoder  字段a,b是两个不同的字段 
      

  6.   


    select 1 只是判断是否有满足条件的值。1是一个数字,随便写的,写成2也可以