I’m running into some trouble filtering my SOQL Query by date where the date field belongs to the child of the object I’m querying.
I couldn’t find anything in the documentation, and I tried two different queries, both of which failed:
SELECT Name, (SELECT Date__c FROM Child__r)
FROM Parent Where Date__c >= <todays_date>
SELECT Name, (SELECT Date__c FROM Child__r)
FROM Parent Where Child__r.Date__c >= <todays_date>
Is this even possible in Salesforce?
Its not totally clear from your question exactly what your trying to filter. But if you want to get a list of parents that have a child record with a date matching some critera then you can use a semi-join, e.g.
You can also add in the child sub query if you want the child data as well e.g.
This will get you the parent that have a child with the criteria, and for each parent, get all the children. You can also filter the sub-query on the same criteria if you only want the children that match the criteria, e.g.
Finally, depending on exactly what you’re trying to do, you can also flip it around and query the child table directly, pulling in data from the parent record, e.g.