You need to sign in to do that
Don't have an account?
Thomas Miller
Accessing Records Returned by SOQL Query W/ Inner Query
Hi all,
Quick question about how to utilize the data I'm getting back from my query. There seems to be some confusion on my side as to how to either make the type correct, because I must return a specific type, or maybe how to modify my query slightly so I am getting back the desired type. There is a lookup relationship between two objects, Review__c and Media__c, the latter being the parent. The query functions in its current state, but I am completely at a loss as to how I might access the data in the "Reviews__r" column, column 2, of said query.
SOQL Query
The above is my query, and it will return a single row. I need the data contined in row 1, column 2, but am unsure how to extract it from the above List<Media__c> and place into a List<Review__c> type to be returned by my getter. If any clarification is needed to help solve this, just say so. Any help is much appreciated!
Best,
Tom
Quick question about how to utilize the data I'm getting back from my query. There seems to be some confusion on my side as to how to either make the type correct, because I must return a specific type, or maybe how to modify my query slightly so I am getting back the desired type. There is a lookup relationship between two objects, Review__c and Media__c, the latter being the parent. The query functions in its current state, but I am completely at a loss as to how I might access the data in the "Reviews__r" column, column 2, of said query.
SOQL Query
List<Media__c> Med = new List<Media__c>(); Med = [SELECT id, (SELECT Review_Submission_Date__c, Comments__c, Media__c, Member__c, Rating__c FROM Reviews__r) FROM Media__c WHERE id =:recId LIMIT 50];
The above is my query, and it will return a single row. I need the data contined in row 1, column 2, but am unsure how to extract it from the above List<Media__c> and place into a List<Review__c> type to be returned by my getter. If any clarification is needed to help solve this, just say so. Any help is much appreciated!
Best,
Tom
Here's the way to do this if anyone else is wondering:
All Answers
Here's the way to do this if anyone else is wondering:
Correct. If you need to iterate through all the Reviews for all the Media, per se, you could also do the following instead of accessing each indice individually: