例:A表,中有,a,b,c字段,B表中也有a,b,c字段,两个表结构是一样的.我想要的是,查询A表中,a字段等于B表中的a字段,但是A表中的c字段不等于B表中的c字段的数据.像这种查询语句如何编写

解决方案 »

  1.   

    select * from ta t where exists(select 1 from tb where a=t.a)
    and not exists(select 1 from tb where c=t.c)
      

  2.   

    select *
    from a 
    where exists(select * from b where a.a=b.a and a.c<>b.c)
      

  3.   


    select * from ta a,tb b
    where a.a=b.a and a.c<>b.c
      

  4.   

    select *
    from a 
    where exists(select 1 from b where a.a=b.a and a.c<>b.c)
      

  5.   

    select * from a where exists(select 1 from b where a.a=b.b and a.c!=b.c)
      

  6.   

    select A表.a,A表b,A表.c from A表,B表 Where A表.a=B表.b And  A表.c<>B表.c
      

  7.   

    ---写错了一点点
    select * from a where exists(select 1 from b where a.a=b.a and a.c!=b.c)
      

  8.   

    select A表.a,A表b,A表.c from A表,B表 Where A表.a=B表.a And  A表.c<>B表.c
      

  9.   

    select * from a where not exists(select 1 from b where a.a=b.b and a.c=b.c)