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
DritterDritter 

SOQL Across Child Records with WHERE Statement

I'm trying to find accounts with a student schools that have a school type of "med_us." However, when I add the WHERE statement to the inner select it times out. See below:

SELECT id, Educational_Background__c FROM Account WHERE ID IN (SELECT Account__c FROM Student_School__c WHERE school_type__c = 'med_us') AND Educational_Background__c = 'IMG'AND createddate = TODAY

If I remove the WHERE statement it runs fine, but it's not giving me the info I need:

SELECT id, Educational_Background__c FROM Account WHERE ID IN (SELECT Account__c FROM Student_School__c ) AND Educational_Background__c = 'IMG'AND createddate = TODAY

When searching for records across child objects are we allowed to use WHERE statements? 

I've also tried this:

SELECT id, Educational_Background__c FROM Account WHERE ID IN (SELECT Account__c FROM Student_School__c) AND Educational_Background__c = 'IMG'AND createddate = TODAY AND school_type__c.student_school__r ='med_us'