如何查找未加入的记录? [英] How do I find records that are not joined?
本文介绍了如何查找未加入的记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个连接在一起的表.
I have two tables that are joined together.
A有很多B
通常您会这样做:
select * from a,b where b.a_id = a.id
要从a中具有b中记录的所有记录中获取.
To get all of the records from a that has a record in b.
我如何只获取b中没有任何内容的a中的记录?
How do I get just the records in a that does not have anything in b?
推荐答案
select * from a where id not in (select a_id from b)
或者像该线程上的其他一些人说的那样:
Or like some other people on this thread says:
select a.* from a
left outer join b on a.id = b.a_id
where b.a_id is null
这篇关于如何查找未加入的记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文