You need to sign in to do that
Don't have an account?
Rajaganagavel
Unable to retrive the records using relationship SOQL Queries Child to Parent
Hi Guys,
In my ORG, I have two custom objects named as follows.
Here Warehouse is Parent Object and Product is Child object.
Also, master-detail relation ship has created with Product_Warehouse_Location field in Product object
But I'm trying to retrive the record using child to parent relationship SOQL queries between the objects
I'm getting the following error in Query editor window.
Product_Warehouse_Location__c, Product_Name__c ,Warehouse__r.Name FROM Product__c
^
ERROR at Row:1:Column:65
Didn't understand relationship 'Warehouse__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Please someone help me on this. Help to identify whats wrong with my query.
Custom Object Parent API Name : Warehouse__c
Fields:
Name
Warehouse_Name__c
Warehouse_Location__c
Custom Obejct Child API Name : Product__c
Fields:
Name
Product_Name__c
Product_Warehouse_Location__c ---Master-Detail(Warehouse)
In my ORG, I have two custom objects named as follows.
Here Warehouse is Parent Object and Product is Child object.
Also, master-detail relation ship has created with Product_Warehouse_Location field in Product object
But I'm trying to retrive the record using child to parent relationship SOQL queries between the objects
I'm getting the following error in Query editor window.
Product_Warehouse_Location__c, Product_Name__c ,Warehouse__r.Name FROM Product__c
^
ERROR at Row:1:Column:65
Didn't understand relationship 'Warehouse__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Please someone help me on this. Help to identify whats wrong with my query.
Custom Object Parent API Name : Warehouse__c
Fields:
Name
Warehouse_Name__c
Warehouse_Location__c
Custom Obejct Child API Name : Product__c
Fields:
Name
Product_Name__c
Product_Warehouse_Location__c ---Master-Detail(Warehouse)
In this case, you can query from child to parent with the help of field specified for master-detail relationship on the child object.
Please use the below query to resolve your issue:
Select Id, Name, Product_Name__c ,Product_Warehouse_Location__r.Name FROM Product__c
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
All Answers
Please use this following query:
Select Id,Product_Warehouse_Location__c, Product_Name__c ,Product_Warehouse_Location__r.Name FROM Product__c
Let me know if it solves your problem.
Many Thanks,
Sunil Rathore
In this case, you can query from child to parent with the help of field specified for master-detail relationship on the child object.
Please use the below query to resolve your issue:
Select Id, Name, Product_Name__c ,Product_Warehouse_Location__r.Name FROM Product__c
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Thanks for your prompt response.
Your query works like charm. Now, I understand that only relationship field should be appended with __r in that query.
Thank you so much guys!!