一个表A,主键为 a,b
从表B导入数据到A,B表结构和A相同,只是没有主键导入时就是提示主键重复。
如何找出B表,a,b两字段相同的数据列来???

解决方案 »

  1.   


    insert into a(a,b)
    select a,b from b bb
    where not exists(select 1 from a where bb.a=a and bb.b=b)
      

  2.   


    select a,b,count(1) from b
    group by a,b
    having count(1)>1
      

  3.   

    select * from B where exists(select 1 from A where A.a=B.a and A.b=B.b)
      

  4.   

    select * from B
    inner join
    (
    select a,b,count(1) from b 
    group by a,b 
    having count(1)=1
    ) t
    on B.a=t.a and B.b=t.b
      

  5.   

    select b.a,b.b from B
    where exists 
    (select * from A where A.a=B.a and A.b=B.b)
      

  6.   

    select * from A_DB where Id in(select Id from B_DB)应该可以把