You need to sign in to do that
Don't have an account?
Dave Dudek
SOQL query with inner select issue
I'm trying to view contacts of accounts that are related to a custom object we have called Our_Role_Service_Affiliation_for_Account__c. I'm able to see the account name, service name and role name but I can't seem to delve into the accounts.
Here's my two SELECT queries I've tried:
1)
SELECT Id,Name,(SELECT Name FROM Contacts),(SELECT Id,Service__r.Name,Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__r) FROM Account WHERE Id IN (SELECT Account__r.Id FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r != 'Outreach')
ERROR at Row:1:Column:171
The inner select field 'Account__r.Id' cannot have more than one level of relationships
2)
SELECT Name,Account__r.Name,Service__r.Name,Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r.Name != 'Outreach' AND Account__r.BillingState = :place.State_Code__c
Works but doesn't show contacts
Here's my two SELECT queries I've tried:
1)
SELECT Id,Name,(SELECT Name FROM Contacts),(SELECT Id,Service__r.Name,Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__r) FROM Account WHERE Id IN (SELECT Account__r.Id FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r != 'Outreach')
ERROR at Row:1:Column:171
The inner select field 'Account__r.Id' cannot have more than one level of relationships
2)
SELECT Name,Account__r.Name,Service__r.Name,Our_Role__r.Name FROM Our_Role_Service_Affiliation_for_Account__c WHERE Our_Role__r.Name != 'Outreach' AND Account__r.BillingState = :place.State_Code__c
Works but doesn't show contacts
Kindly update your 1st SOQL like below add GROUP BY
let me know if this help you.
Thanks
Lokesh
Can you try this ?
Thanks
Brahma
Can you tell the API name of Account relationship in Our_Role_Service_Affiliation_for_Account__c
Please try this.
There was some typo in my earlier post.
Thanks
I am trying to get list of account name from Account object:
SELECT Name FROM Account;
But having following error on developer console query editor
Unknown error parsing query
Can anybody help me