function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RDN_LHRRDN_LHR 

SOQL Relationship question

Hi,

 

I have a custom field on my Account object called CSR__c for a Customer Service Rep which is related to User.  If I want two emails, one for the CSR__c and one for the Account Owner, I do something like this to get what I need:

 

    select Id, Name, Owner.Email, CSR__r.Email from Account where  ...

 

 

However, today, I would like to select this information about a Contact's Account in one statement.  I would really love to be able to write:

 

      select Id, Firstname, Lastname, Account.Owner.Email, Account.CSR__r.Email from Contact where ....

 

 

 

Is this possible to write somehow, using one query?  Am I close at least?

 

Thanks!!

Message Edited by RDN_LHR on 01-22-2009 10:21 AM
SuperfellSuperfell
looks about right, what's the error you get ?
werewolfwerewolf
Perhaps you're just confused by the Eclipse schema browser's tendency to show data from related items as a link instead of a straight string, as was this poster?  Rest assured that even if it appears as though there's some kind of related object you have to navigate through, for parent lookups like the one you're doing, you can reference the items directly as a string in your code (in your case, as Account.CSR__r.Email).