select a_id from A where a_id not in (select distinct b_aid from B where b.a_aid = a_id)

解决方案 »

  1.   

    请问,不加条件不行吗?多谢windindance
      

  2.   

    你的a_id与b_aid的类型是不是字符型且长度不同?
      

  3.   

    select * from a
    where a_id not exists(select a.a_id from a,b where a.a_id=b.b_aid)
      

  4.   

    长度类型都是一样的,我想问一下,加上where b.b_aid=a_id 和不加有差别吗?
      

  5.   

    我不知道你的库是什么回事,可我用下边的语句一点错也没有。
    create table a(
     id   int)
    create table b(
     id   int)
    select distinct id from a where a not in (select distinct id from b)
    我的表可一点要求都没有
      

  6.   

    不妨试一试这句,首先说明,我没试,不一定能成。
    select a_id from A where a_id in (select distinct b_aid as a_aid from B);