-2

我有两个表,组和机构组加入:

groups                      agencygroupjoins
--------------------        --------------------
groupID                     joinID
groupName                   agencyID
                            groupID

如何获取所有 groupID、groupName 记录(来自组),其中 groupID 在 Agencygroupjoins 中找不到?

4

1 回答 1

3

使用外连接

SELECT groups.*
FROM   groups LEFT JOIN agencygroupjoins USING (groupID)
WHERE  agencygroupjoins.groupID IS NULL
于 2013-03-14T20:24:36.343 回答