select * from a where a.id in(select id from b);
相当于
select * from a where exists(select id from b wherea.id=b.id);

解决方案 »

  1.   

    谢谢。
    not exists和not in的区别呢?也像上面那样呢?
      

  2.   

    select * from a where exists(select id from b wherea.id=b.id);

    select * from a where exists(select id from b);
    难道上面两句不是一回事么?请指教:)
      

  3.   

    select * from a where exists(select id from b where a.id=b.id);
    --B表有id=a.id的数据才返回TRUE

    select * from a where exists(select id from b); 
    --只要B表有数据就返回TRUE
      

  4.   

    这应该和NULL有关系
    你看看NULL方面的
      

  5.   

    学习,我现在也搞不明白exists的意思!