表A   字段名称 A1 A2 A3
                1  2  3
                4  4  5表B   字段名称 B1 B2 B3
                1  2  3
  问题是: 如何根据表B 的数据列B1 查找出表A 中不同于表B的数据行          既要求结果显示:    表A    A1  A2  A3  
                                     4   4   5 谢谢大家的帮助!

解决方案 »

  1.   

    select a.* from a left join b on a.a1=b.b1 and a.a2 = b.b2 and a.a3=b.b3 where b.b1 is null不知道这样行不行。
      

  2.   

    select t.a1, t.a2, t.a3
    from
    (select a.*, b.*
    from a
    left join b
    on a1 = b1 and a2 = b2 and a3 = b3) t
    where t.b1 is null 
      

  3.   

    select * from  表A where  A1 not in(select  B1 from 表B )手写的
      

  4.   

    如果是在2005及其以上版本,可以使用
    select * from a except select * from b
      

  5.   

    1.select a.*
    from a left join b on a1=b1 and a2=b2 and a3=b3
    where b1 is null
        [align=center]====  ====
    [/align]
      

  6.   

    2.select * 
    from a
    where not exists ( select b1 from b where b1=a1 and b2=a2 and b3=a3)
        [align=center]====  ====
    [/align]
      

  7.   

    select * from A WHERE NOT EXISTS (SELECT 1 FROM B WHERE  B1=A.A1 )
      

  8.   

    3.select a1,a2,a3
    (
    select * from a
    union all
    select * from b
    )
    group by a1,a2,a3
    having count(*)=1
        [align=center]====  ====
    [/align]
      

  9.   

    select * from a where a.a1 not in (select b1 from b)