function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Suja RajSuja Raj 

SOQL Query HELP to pull child record id from associated parent record id

Hi, please help me with this query.
 i want child record id with associated parent record id e.g
parent id=a8u540000004CWVAA3
i need all the associated child record id FROM PATENT ID

SELECT Name,id, (SELECT ID FROM CHILD OBJECT__R)  FROM parent object__c  where id IN ('a8u540000004CWVAA3','a8u540000004CWBBC4')

Thanks

,
sharathchandra thukkanisharathchandra thukkani
query seems to be correct. Please check whether the API names are proper or not.
Anupama SamantroyAnupama Samantroy
Hi Suja,
Please check the API names as the query syntax is correct. Please make sure to take the right child relationship name for ChildObject__r. You will get this from the relationship field of the child object.

Thanks
Anupama
Suja RajSuja Raj
Hi ,
Thanks for your feedack but am getting this error,Please help.....
All am trying to get all the child record id for the provided parent record id.

SELECT Name,id, (SELECT ID,name FROM Cell_Block__r)  FROM Classic_Project__c  where id IN ('a8uE0000000gItR','a8uE00000004FDU')

INVALID_TYPE: 
Name,id, (SELECT ID,name FROM Cell_Block__r) FROM Classic_Project__c
^
ERROR at Row:1:Column:38
Didn't understand relationship 'Cell_Block__r' in FROM part of query call. 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.
Anupama SamantroyAnupama Samantroy
Hi,

There could be 2 possibilities:

1. If the relationship is lookup then please check the field level security. You might not have the permission to read that field on child object.
2. If its a master detail then could you please check if there is any namespace  prefix defined in your org. 
  ​Setting>Packages>Namespace Prefix. 
If so then you need to prefix that with the child object name i.e namespace__

Cell_Block__r.
​​

​Please mark best answer if this answers your question.​
Thanks and Regards
Anupama Samantroy
Rishabh Shrivastava 12Rishabh Shrivastava 12
Instead of using Cell_Block__r use Cell_Blocks__r