You need to sign in to do that
Don't have an account?
JJ1234
Query other related items of the same object from the current related item's Master object--SOQL
Hello,
I'm relatively new to SOQL and Conga Query builder and am attempting to query related data of the same object, using a lookup of the current object. Here is how the objects are related:
From the current Custom object, I have a lookup relationship to accounts--the field is Primary Account. I'd like to query all other related objects of the same type as the current object. My statement looks like this so far, however, it is failing.
SELECT Custom_Field1__c, Name FROM Custom__c WHERE Primary_Account__r.Id = Primary_Account__c.Id
Primary_Account__r.Id is the ID of the Master "Primary Account" on the Custom record, but the query doesn't seem to be pulling the Id to match from the current custom object so that the query can pull all related Custom_Field1 and Name fields from the other custom objects related to the Primary Account. I hope this all makes sense.
Thank you in advance.
I'm relatively new to SOQL and Conga Query builder and am attempting to query related data of the same object, using a lookup of the current object. Here is how the objects are related:
From the current Custom object, I have a lookup relationship to accounts--the field is Primary Account. I'd like to query all other related objects of the same type as the current object. My statement looks like this so far, however, it is failing.
SELECT Custom_Field1__c, Name FROM Custom__c WHERE Primary_Account__r.Id = Primary_Account__c.Id
Primary_Account__r.Id is the ID of the Master "Primary Account" on the Custom record, but the query doesn't seem to be pulling the Id to match from the current custom object so that the query can pull all related Custom_Field1 and Name fields from the other custom objects related to the Primary Account. I hope this all makes sense.
Thank you in advance.
This just an example of how the parent-child query works.
Ways of writing Parent-Child Queries for Standard Objects Ways of writing Parent-Child Queries for Custom Objects SELECT Custom_Field1__c, Name FROM Custom__c WHERE Primary_Account__r.Id = Primary_Account__c.Id
The above query is yours which you mention.
You can't use a where clause like above.
Have a look at the following for the right way to query: I hope you find the above solution helpful. If it does, please mark it as the Best Answer to help others too.
Thanks and Regards,
Sachin Arora
www.sachinsf.com