现在有A表B表
A 里有c字段 B里也有c字段
去除A.c 记录 和 B.c记录相同的值
显示A中所有A.c和B.c不相同的其余c记录使用过1.select c from A(select c from B,A where B.c=A.c) F  where A.c<>F.c
      2.select A.* from A where A.c not in (select B.c from B)
  结果都不对最后不要用join我该怎么做 %>_<%

解决方案 »

  1.   

    ◎去除A.c 记录 和 B.c记录相同的值
    这个去除是啥意思?查询出来就行了吧?
    Select *
    From A, B
    Where A.c = B.c
    ◎显示A中所有A.c和B.c不相同的其余c记录
    Select Distinct c From (
      Select c From A
      Union
      Select c From B
    )
      

  2.   

    先把A的c与B相同选出来
    select A.C form A,B WHERE A.C=B.C;
    在分A里不同的c出来
    SELECT A.C FROM A WHERE A.C NOT IN (select A.C form A,B WHERE A.C=B.C
    )
      

  3.   

    select * from A where not exists (select NULL from B where A.C = B.C)满足你的要求
      

  4.   

    select c from (Select c From A Union Select c From B) t where t.c not in (select A.c from A,B where A.c = B.c)
      

  5.   

    select c from (select c from A union select c from B) t where t.c not in(select c from A,B shere A.c<>B.c);
      

  6.   

    如果A、B关于C关联记录数量小于不关联记录数,则推荐使用not exists方式,否则推荐使用not in方式
    ps:这已经跑题到谁写的sql效率最高上面了
      

  7.   

    SELECT * FROM A WHERE A.c not in (SELECT c FROM B) 
      

  8.   

    你的意思是不是想求两个表的差集select A.c
      from A
    uinus
    select B.c
      from B
      

  9.   

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

  10.   

    如果只要列C字段,用以下语句可以:
    SELECT C FROM A UNION 
    SELECT C FROM B WHERE C NOT IN(SELECT C FROM A);
      

  11.   

    是求两个表中c字段的并集的话!直接使用select c from A
    union select c from B