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
Pal2011Pal2011 

Access related list of Account Object using SOQL Query

Hi,

 

I've created one child object called Rebate which has Master-Detail relationship with Account object. In my Batch Apex I'm trying to access related list of Rebate object on an Account object.

 

Here is my SOQL query:

Select (Select Id, Owner__c, Year__c From Account_Rebates__r) From Account a

 

When I'm running this query on salesforce.schema browser, I'm not getting any record but what I'm getting is red square.  I'm not sure what is going wrong on my end.

 

Can you please help me with this?

 

Thanks.

TBouscalTBouscal
__r is used to access the fields on the Account_Rebates__c object.

Select (Select Id, Owner__c, Year__c From Account_Rebates__c) From Account a

Select (Select Id, Owner__c, Year__c From Account_Rebates__r.createddate) From Account a