You need to sign in to do that
Don't have an account?

SOQL Question
I have a SOQL query like the following
Select a.id,a.name,a.lastmodifiedby,(select id from related_accounts__r where main_account__c = '') from account where a.id = ''
Basically teh related_accounts__r is a child relationship for the account object.
I am not sure how would I access the inner id in my code?
I think I have done this in the past but don't remember how?
Thanks
I have a SOQL query like the following
Select a.id,a.name,a.lastmodifiedby,(select id from related_accounts__r where main_account__c = '') from account where a.id = ''
Basically teh related_accounts__r is a child relationship for the account object.
I am not sure how would I access the inner id in my code?
I think I have done this in the past but don't remember how?
Thanks
the outer account records will have a related_accounts__r property that's an array of the inner rows for that outer row, so you'd do something like
for (Account a: [select ....]) {
for (related_account__c r : a.related_accounts__r) {
System.debug (r.id + " is a child of " + a.id);
}
}