SQL 新手。构建我的第一个联系人管理器项目。当前架构如下所示。
问题:
- 我正在研究显示给定联系人的所有联系人类型(电话、电子邮件、社交、地址)的视图。
- 我将以下尝试放在一起,但它仅
contactGUID
在每个 contact_type 表中都返回结果。
--Problem: Only returns records if contactGUID is present in every contact_type table
SELECT
c.contGUID, c.contType,
i.indTitle, i.indFirstName, i.indMidName, i.indLastName,
e.emailAddress, e.emailDomain,
p.phnCountryCode, p.phnAreaCode, p.phnNumber,
s.socURL, s.socHandle,
a.addrCountry, a.addrCountryCode, a.addrCountrySubdivision, a.addrCountrySubName, a.addrSecondarySubdiv, a.addrMunicipality, a.addrMuniSubdivision, a.addrStreetNumber, a.addrStreetName, a.addrPostalCode, a.addrLatitude, a.addrLongitude
FROM
CONTACT c
JOIN INDIVIDUALS i
ON c.contGUID = i.indGUID
JOIN CONTACT_EMAIL ce
ON c.contGUID = ce.contactGUID
JOIN EMAILS e
ON ce.emailGUID = e.emailGUID
JOIN CONTACT_PHONE cp
ON c.contGUID = cp.contactGUID
JOIN PHONES p
ON cp.phnGUID = p.phnGUID
JOIN CONTACT_SOCIAL cs
ON c.contGUID = cs.contactGUID
JOIN SOCIALS s
ON cs.socGUID = s.socGUID
JOIN CONTACT_PHYS_ADDRESS cpa
ON c.contGUID = cpa.contactGUID
JOIN PHYS_ADDRESSES a
ON cpa.addrGUID = a.addrGUID
问题:
CONTACT_PHONE
如果给定的记录不存在,我如何返回所有其他联系类型(电子邮件、社交、地址)contactGUID
?