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
iyappan kandasamy 4iyappan kandasamy 4 

From child to parent soql query

From child-Parent soql
----------------------------
Parent = college
child =student(lookup with parent)
relation =Students

written query as

for(Student__c s:[select Name,college__r.Name,CollegeName__c from student__c])
{
  system.debug('student Name:'+s.Name+'     college Name:'+s.college__r.Name);
}

but error as

Line: 3, Column: 18
select Name,college__r.Name,CollegeName__c from ^ ERROR at Row:1:Column:13 Didn't understand relationship 'college__r'
Best Answer chosen by iyappan kandasamy 4
Amit Chaudhary 8Amit Chaudhary 8
Try like below

for(Student__c s:[select Name,collegeName__r.Name,CollegeName__c from student__c])
{
  system.debug('student Name:'+s.Name+'     college Name:'+s.collegeName__r.Name);
}

Let us know if this will help you.

Issue was your API name.
 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Please click on College field (Lookup Field) on Student object . And share the screen shot with child relationship Name.
Prashant Pandey07Prashant Pandey07
+for Amit,Please check the right API name of lookup field on the Student object..

--
Thanks,
Prashant
iyappan kandasamy 4iyappan kandasamy 4
User-added image
Prashant Pandey07Prashant Pandey07
you need to use collegeName__r.Name


--
Thanks,
Prashant
Amit Chaudhary 8Amit Chaudhary 8
Try like below

for(Student__c s:[select Name,collegeName__r.Name,CollegeName__c from student__c])
{
  system.debug('student Name:'+s.Name+'     college Name:'+s.collegeName__r.Name);
}

Let us know if this will help you.

Issue was your API name.
 
This was selected as the best answer
iyappan kandasamy 4iyappan kandasamy 4
Really thanks a lot...It is working fine as per your directions ...thanks again Amit .....thanks a lot
Emily WillsonEmily Willson
It might be possible that this (https://admission-writer.com/blog/specific-types-of-essays) would help you. Take a close look.
Jennifer Pauli 8Jennifer Pauli 8
Thank you, it helped me a lot. I am currently running my educational blog and it would be nice if you could take a look at it on this page (https://betterwritingservices.com/reviews/essaypro-com/). I really enjoy helping students to get fascinating and useful information. My posts is supposed to help you realize how to write an essay with confidence and a bit more focus.