You need to sign in to do that
Don't have an account?
el hadri oussama
Junction object join soql help needed
Hello ,
I need help to be build a join query for a junction object , I had a junction object StudentCourse__c that join Member__c and Course__c Objetcs , I want to be able to select a list of studentCourse based on a list of members and courses .
the list of members :
the list of courses:
I loop membres or courses so I need a way to retrieve all the StudentCourses whitout using a loop.
Thank you in advance
I need help to be build a join query for a junction object , I had a junction object StudentCourse__c that join Member__c and Course__c Objetcs , I want to be able to select a list of studentCourse based on a list of members and courses .
the list of members :
students= [select id, Name,FirstName__c from Member__c where id in(select Student__C from StudentCourse__c where Course__r.Year__c= : schoolYear ) and School__c=: school and Grade__c= :gradeclasse];
the list of courses:
courses= [select id ,Name ,Scale__c ,Subject_Name__c from Course__c where Grade__c= : gradeclasse and School__c= :school];to retrive one record it's easy you just call the query below but the problem is I am exceeding the limits when
I loop membres or courses so I need a way to retrieve all the StudentCourses whitout using a loop.
StudentCourse__c studentCourse = [select id from StudentCourse__c where Course__c= :course.ID and Student__c= :student.ID];
Thank you in advance
You can use a list of studentCourse instead of using a loop. or, When you retrieve over 50000 records, @ReadOnly annotation is required.
See also,
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_loops_for_SOQL.htm
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_ReadOnly.htm