/services/data/v26.0/query?q=select+a.Id,+(select+c.Id,+c.FirstName,+c.GUID__c,+c.LastName,+c.Middle_Name__c,+c.Phone,+c.Email,+c.Professional_Role__c,+c.HCP__c+from+Contacts+c)+from+Account+a +where+a.Contacts!=null
I am using this i am running into error of no field found named contacts.
How will i get only those accounts with corresponding contacts which have atleast one contact.
I want to eliminate all those accounts that has no contacts .Please note i want to do it in a single REST API call.
Attribution to: Mohith Shrivastava
Possible Suggestion/Solution #1
How about this?
Only Accounts with Contacts
SELECT Id, Name, (SELECT Email FROM Contacts)
FROM Account
WHERE Id IN (SELECT AccountId FROM Contact)
The subquery in SELECT optional of course (do you want the contacts returned too or not?)
Only Accounts that have no Contacts
SELECT Id, Name
FROM Account
WHERE Id NOT IN (SELECT AccountId FROM Contact)
Attribution to: eyescream
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4213