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
Sathya CSathya C 

I tried to get custom child record when parent object information is given. But, How to query for custom parent record when custom child field is given?

// student__c is child, college__c is parent. The below code to get the child record when parent information is given works
    {
          student__c [] a = [select id, name, date_of_birth__c, phone__c, email__c, address__c from student__c where     college_name__r.name = 'PEC College'];
          for(student__c s:a)
          system.debug(s);    
    }

//The code below to get parent record when child information does not.
    {
          college__c a = [select id, name, address__c, courses_offered__c, dean_name__c, number_of_students__c, year_started__c
                        from college__c where id in (select student__r where student__c.name = 'Claire Hale') ];
      }

 
AnjithKumarAnjithKumar
Hello Satya,
college__c a = [select id, name, address__c, courses_offered__c, dean_name__c, number_of_students__c, year_started__c
                        from college__c where id in (select college__c  where student__c.name = 'Claire Hale') ];

Hope it helps you.

Thanks,
Anjith kumar.
Sathya CSathya C
Hi Anjith, 
Its still not working
AnjithKumarAnjithKumar
sorry  try this.
 
college__c a = [select id, name, address__c, courses_offered__c, dean_name__c, number_of_students__c, year_started__c
                        from college__c where id in (select college__c  from student__c where name = 'Claire Hale') ];


Thanks,
Anjith