I have an account with 4 contacts, two are direct and two are indirect contacts. I'm trying to retrieve all 4 contacts in an SOQL query but can't seem to get it to work .
For example if I run this query in the developer console I get back all 4 records and it shows the same Account.Id for all records (note i'm using my developer account that only has a single Account and the 4 contacts for these tests.
SELECT Id, Name, Email, Account.Id FROM Contact
But if I ask for the Contacts by specifying the Account
SELECT Id, Name FROM Contact where Account.Id = '<SOME_VALID_ID>'
I only get the two direct contacts . Similarly when I run this query to get all the contacts for an account I also only ever get the two direct contacts back.
SELECT Id, Name, (SELECT AccountId, Name, Email, HomePhone FROM Contacts where AccountId = '<SOME_VALID_ACC_ID'>) FROM Account WHERE Id = '<SOME_VALID_ACC_ID'>
This query also only returns true if don't constrain the inner SELECT on AccountId. If anyone could let me know if this is possible and how to do it I'd greatly appreciate it.