我有以下表格:
companyContacts
addresses
states
phoneNumbers
我需要在 、 和 上进行addresses
LEFT states
JOIN phoneNumbers
。我需要与 连接,phoneNumbers
并且需要与连接。addresses
companyContacts
states
addresses
我可以进行如下选择来获取所有内容。但是,如果某人有地址而不是电话号码,则不会返回结果。我如何才能使两者phoneNumbers
都addresses
从 加入companyContacts
?
SELECT * FROM
companyContacts AS c
LEFT JOIN phoneNumbers AS p
ON c.entityID = p.entityID
LEFT JOIN addresses AS a
ON p.entityID = a.entityID
LEFT JOIN states AS s
ON a.stateID = s.id