You need to sign in to do that
Don't have an account?
Chris Collier 6
SOQL query on three objects (two standard and one custom)
I'm trying to query across three objects:
Trying the following:
I get:
Trying this:
I get:
What is the correct way to write this query?
- Account
- Contact
- Transaction (custom)
- The relationship from Transaction to Account is AcountId__r
- The relationship from Account to Contact is Contacts (correct me if I'm wrong)
- Name is a field on Transaction
- Names of all Transactions
- Names of the associated Accounts
- Ids of the Contacts associated with those Accounts
Trying the following:
SELECT Name, AccountId__r.Name, AccountId__r.Contacts.Id FROM Transaction__c
I get:
ERROR at Row:1:Column:33 Didn't understand relationship 'Contacts' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Trying this:
SELECT Name, AccountId__r.Name, (Select AccountId__r.Contacts.Id FROM AccountId__r) FROM Transaction__c
I get:
ERROR at Row:3:Column:6 Didn't understand relationship 'AccountId__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
What is the correct way to write this query?
Hi
Try this