比如表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)

posted on 2009-03-17 15:24  Madream.F  阅读(217)  评论(0编辑  收藏  举报