两个表 A表ID   name 
1     a1
2     a2
3     a3
4     a4B表ID     name
1       b1
2       b2
5       b5用sql语句,返回B表结果:ID     name
5       b5也就是B表与A表对应返回B表中A表不存在的内容

解决方案 »

  1.   

    select * from B表 as b
    where not exists(select * from A表 as a where a.ID = b.Id)
    同样
     select * from B表 as b
    where not in(select a.Id from A表)
      

  2.   

    select * from B表 as b 
    where a.Id not in(select a.Id from A表) 
      

  3.   

    select b.id, b.name from a, b where a.id<>b.id
      

  4.   

    日TMD写错
    select * from B表 as b 
    where b.Id not in(select a.Id from A表) 
      

  5.   

    select * from B where id not in(select B.id from B inner join A on A.id=B.id)
      

  6.   

    select * from B where id not in(select id from A)
      

  7.   


    select b.id,b.name from a,b where a.id<>b.id
      

  8.   

    select b.* from B b where b.id not in(select a.id from A a)
      

  9.   

    也就是B表与A表对应返回B表中A表不存在的内容
    这话读起来有点累
    --------