6

I want to write a soql query , My scenario is as follows. I have three objects objectA,objectB,objectC. objectA is the parent object for both objectB,objectC.

  • objectA - objectB (Master-detail relationship)
  • objectA - objectC (Master-detail relationship)`

ObjectB has two fields:

  • Start_date__c
  • End_date__c

ObjectC has a field:

  • Date__c

Now i want to retrieve records with date__c in objectC those were in between start_date__c and end_date__c of objectB. how can i achieve such functionality .

1
  • 2
    Is there always exactly one ObjectB record on an ObjectA? Or are you dealing with a specific ObjectB? May 21, 2014 at 13:18

1 Answer 1

4

You can try to query the junction object like this:

Select ObjectC__r.Id, ObjectC__r.Name
From ObjectA__c
Where ObjectC__r.Date__c >= ObjectB__r.start_date__c
And ObjectC__r.Date__c <= ObjectB__r.end_date__c
1
  • 1
    the __r syntax in your example is referencing the child (many) side of the relationship and isn't valid.
    – Mark Pond
    May 21, 2014 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .