比如有表A,里面有3个字段F1,F2,F3
表B,里面也有3个字段F1,F2,F3现在想找出在A表和B表里F1,F2两个字段都相同的记录,然后导出
F1,F2,A.F3,B.F3这样的记录,请问sql语句怎么写?

解决方案 »

  1.   

    select a.f1,a.f2,a.f3,b.f3 as bf3
    from a,b
    where a.f1=b.f1 and a.f2=b.f2
      

  2.   

    SELECT * FROM TableA INTERSECT SELECT * FROM TableB;
      

  3.   

    orSELECT * FROM TableA  as where exists(SELECT * FROM TableB where F1=a.F1 and F2=a.F2 and F3=a.F3);
      

  4.   

    现在想找出在A表和B表里F1,F2两个字段都相同的记录,然后导出
    F1,F2,A.F3,B.F3这样的记录,请问sql语句怎么写?---找出F1,F2两个字段都相同的记录select * from a where exists(select 1 from b where f1=a.f1 and f2=b.f2)--导出F1,F2,A.F3,B.F3这样的记录
    select a.f1,a.f2,a.f3,b.f3 as bf3 from a,b where a.f1=b.f1 and a.f2=b.f2