select * from A where a_id not in(select b_id from B)

解决方案 »

  1.   

    谢谢czliang,但是mysql报错"#1064 - You have an error in your SQL syntax near 'SELECT a_id FROM B) LIMIT 0, 30' at line 1"。
    我试了下用select * from A where a_id not in (2,3)可以查询成功,为什么呢?
      

  2.   

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

  3.   

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

  4.   

    select * from a,b where a.id!=b.id
      

  5.   

    select * from a,b where a.a_id!=b.a_id
      

  6.   

    但是mysql报错"#1064 - You have an error in your SQL syntax near 'SELECT a_id FROM B) LIMIT 0, 30' at line 1"。'SELECT a_id FROM B' 应该是 'SELECT b_id FROM B'吧
      

  7.   

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

  8.   

    select A.aid from t left join B on A.aid =B.aid where B.aid is null