You need to sign in to do that
Don't have an account?
How do I filter a SOQL Query (parent/child) to not show recordsets where the child is empty?
I am using a custom object which is a child of the account object.
If I run this query:
Select a.Name, (Select Partner_Research_Name__c, Partner_Research_URL__c From Partner_Research_Records__r) From Account a
I get a list of all accounts some of which contain a record Partner_Research_Records__r that is blank, and others (when the object is present in the parent object) a set of values.
I want to add something to the where clause that will filter out any responses where the Partner_Research_Records__r recordset is null, however I can't seem to figure out the proper syntax.
There are a couple of ways to do this.
1: You can filter your query to only look at Accounts that have the child records. Your query would look like:
This gathers a list of all the account IDs from your partner research records where the Account__c field is not empty. This will be a list of all the accounts that have childre. Applied as the filter, only accounts with children will show up.
2. You can create a rollup summary field on the account that is a count of the number of child records. You can then apply a filter to your query to be:
Hope this helps.
Jay
All Answers
There are a couple of ways to do this.
1: You can filter your query to only look at Accounts that have the child records. Your query would look like:
This gathers a list of all the account IDs from your partner research records where the Account__c field is not empty. This will be a list of all the accounts that have childre. Applied as the filter, only accounts with children will show up.
2. You can create a rollup summary field on the account that is a count of the number of child records. You can then apply a filter to your query to be:
Hope this helps.
Jay
Thank you! You just solved my problem as well.
Regards,
GHDsports apk (https://ghdsports.fun/)
AppValley App https://appvalley.one/download-appvalley-ios/