You need to sign in to do that
Don't have an account?
Sindhu Ambarkar
soql query issue for child to parent relationship
I have two custom objects Job_Application_c,review__c
I need to write child to parent relationship soql query.
Please help me
Thanks & Regards,
Sindhu Ambarkar.
I need to write child to parent relationship soql query.
Please help me
Thanks & Regards,
Sindhu Ambarkar.
You can use something like this to fetch the parent field info using child SOQL:
[select Job_Application_r.Id from review__c];
Make sure you specify the correct relationship API name for Job_Application_c lookup field on review__c object.
If Job_Application__c is the child Object and Review__c is the parent object then
If Review__c is the child Object and Job_Application__c is the parent object then
Also look into the below links for more information about Relationship Queries:
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_understanding.htm
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships.htm
https://developer.salesforce.com/page/A_Deeper_look_at_SOQL_and_Relationship_Queries_on_Force.com
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_lookup.htm
https://developer.salesforce.com/blogs/developer-relations/2013/05/basic-soql-relationship-queries.html
Please do let me know if it helps you.
Regards,
Mahesh
Please follow the below explanation and examples to solve your problem ☁️⚡️
1. Child To Parent Relationship :
Consider Contact (Child) and Account (Parent) relationship.
In the child to parent relationship, relationship name will be a parent object which means a foreign key is an Account object.
#1 Example :
#2 Example : Write a query to fetch list of Contact and Account names from contact object where Account.Industry = 'Media'
NOTE: When we use relationship name to the custom objects in the SOQL query. We should append ObjectName__r to the relationship name.
For Example :
NOTE: When you are writing a query from child to parent relationship always a relation will be master-detail field name (or) lookup field name.
For Example:
Write a query to fetch a list of the transaction along with Account type and customer names whose transaction type is a deposit. (NOTE: Master-Detail field in the transaction is customer details__c).
So these are the ways you can use the child to parent relationship query efficiently.
For More Information Please Follow Below Link To Know More :
https://www.salesforcekid.com/2019/05/salesforce-soql-relationship-queries.html
Wishing You Happy Learning ☁️⚡️
Please Let Me Know If This Helps
Thank You,
Ajinkya Dhas ☁️⚡️
http://www.salesforcekid.com