谢谢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)可以查询成功,为什么呢?
select * from A where a_id not in(select a_id from B)
select * from a where not exists(select a_id from b where a_id=a.a_id)
select * from a,b where a.id!=b.id
select * from a,b where a.a_id!=b.a_id
但是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'吧
select * from A where a_id not in(select a_id from B)
select A.aid from t left join B on A.aid =B.aid where B.aid is null
我试了下用select * from A where a_id not in (2,3)可以查询成功,为什么呢?