I am trying to write a SOQL query to pull out a number of items from 3 Objects - Contact, Account and Case.
I have the following code:
SELECT id, accountid, contactid, contact.primary_contact__c FROM case WHERE contact.Phone = '+6491234567' order by contact.primary_contact__c asc
Which returns a result if the Contact has an open Case related to them.
However, I'm trying to do an equivalent of a SQL Join - whereby I get NULL values and pulling from the Contact object:
SELECT id, accountid, primary_contact__c, (select id from case) FROM contact WHERE Phone = '+6491234567' order by primary_contact__c asc
(So the query will always return the ID of the Contact, the Account ID, etc. and if there is a case assigned against that contact, the case ID)
However the second query does not work - I know that the Relationships exist (otherwise the first query would not work) however, I'm not sure what I'm doing wrong here.