You need to sign in to do that
Don't have an account?
Dritter
SOQL across child records with WHERE statment
I'm trying to find accounts with a student school that has 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 what I'm looking for:
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 in the inner select?
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'
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 what I'm looking for:
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 in the inner select?
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'
If that's the case - then I think You'll need to goto Student_School__c as your main table. Maybe something like this?
SELECT id,Account.Educational_Background__c, StudentIDOrOtherFields
FROM Student_School__c
WHERE School_type__c = 'med_us'
AND Account__r.Educational_Background__c = 'IMG'
AND Account__r.CreatedDAte = TODAY
All Answers
If that's the case - then I think You'll need to goto Student_School__c as your main table. Maybe something like this?
SELECT id,Account.Educational_Background__c, StudentIDOrOtherFields
FROM Student_School__c
WHERE School_type__c = 'med_us'
AND Account__r.Educational_Background__c = 'IMG'
AND Account__r.CreatedDAte = TODAY