我有两个表,组和agencygroupjoins:
groups agencygroupjoins
-------------------- --------------------
groupID joinID
groupName agencyID
groupID
如何获取在agencygroupjoins中找不到groupID的所有groupID,groupName记录(来自群组)?
答案 0 :(得分:3)
使用outer join:
SELECT groups.*
FROM groups LEFT JOIN agencygroupjoins USING (groupID)
WHERE agencygroupjoins.groupID IS NULL