You need to sign in to do that
Don't have an account?
jdogsailing
Querying many-many Relationships
I have established a many-many relationship between Survey and Question objects using a SurveyQuestion junction object and two master-detail relationships as suggested. I'm now tearing my hair trying to query accross the relationship. I'm still an Apex SOQL noob so I must have missed something obvious but how would I:
- select all Questions for a Survey in a single query?
- select all Surveys for a Question in a single query?
Extra credit:
SurveyQuestion has an order_in_survey field. In the first query, I'd like the Questions ordered by it.
Jeff
select question__r.field1, question__r.field2 from surveyQuestion where survey__c = 'some servey id' order by order_in_survey
select survey__r.field1 from surveyQuestion where question__c = 'some question id'