I have a piece of code in my Apex:
List<sObject> assessmentToQuestions = [
SELECT Id, (SELECT Id FROM zced__Assessment_Questions__r) questions
FROM zced__Assessment__c
WHERE zced__Interaction__c = :interactionId
];
Set<String> questionsIds = new Set<String>();
for(sObject assessment: assessmentToQuestions) {
for(sObject question: assessment.questions) {
questionsIds.add(question);
}
}
The code above does not work because it does not allow me to use alias for the list of Id
over here:
(SELECT Id FROM zced__Assessment_Questions__r) questions
I saw the application of an alias over here and tried to do the same, but got an error. So, my question here is how can I use an alias in the case?
Oh (this question in case if it is an x-y problem
) how can I approach the problem of iterating the list in another way? I need to be able to iterate over all the Id
extracted over here:
(SELECT Id FROM zced__Assessment_Questions__r)