Use subquery in SOQL

Salesforce allows us to use subquery in SOQL.
The following soql is a sample, shows how to filter out Parent Records that don’t have a related child with subquery.

And subquery also works in Related(Lookup) Objects, e.g.

Be attention that the object name have to be Child Relationship Name when subquery SELECT as a field, e.g.

“ChildObjects__r” is the “Child Relationship Name” which can be found in “Custom Field Definition Detail” page.

ParentRelation

Post Tagged with , ,