テーブルとテーブルからservice_contacts 含むことができるテーブルが1つあります。 とテーブルの間に関係があります。listidslistscontactidscontactscontact_list_relationshipcontactslists
、または(各リストに含まれているcontactid)にある可能性のあるすべての連絡先をプルしようとしています。service_contactslistidcontactids
SELECT d.* FROM service_contacts a
LEFT JOIN lists b
ON a.calllistid=b.listid
LEFT JOIN contact_list_relationship c
ON c.listid=b.listid
INNER JOIN contacts d
ON d.contactid=c.contactid OR d.contactid=a.contactid
WHERE a.memberid=12345
これが実行され、期待される結果が得られます。これまでのところ...もっと良い方法があるのではないかと思っています。