现在 我有两个表
A表
name id city info
a    1   D 12313132
b    2   C 154562
a    2   E 23124
b    1   C  4546
B表
name id city info
a    1   D 12313132
b    2   C 154562
a    2   E 23124
b    1   C  4546
a    3   C  34234每个表都有很多数据,我想查出 那些 在B表中 有数据,但是A表中不存在的数据其中name,id,city 组合可以判断那些在B表中有,A表中没有,但是Sql怎么写啊

解决方案 »

  1.   

    select name,id,city from B
        minus
    select name,id,city from A
      

  2.   

    select * from B b where not exists(
        select 1 from A where name = b.name and id = b.id and city = c.city
    )
      

  3.   

    select * from B b where not exists(
      select * from A a where a.name = b.name and a.id = b.id and a.city = c.city
    )
      

  4.   

    select * from B b where not exists(
      select 1 from A where name = b.name and id = b.id and city = c.city
    )