比如表A主键id与表B的外键a_id关联,要在A表中查出id不等于B表中所有a_id的记录:not in 写法: select * from A where id not in (select a_id from B where a_id = A.id )not exists写法: select * from A where id not exists (select 1 from B where a_id = A.id)