I have two custom objects in a master detail relationship where Proposal is parent and Question is child.
I need to create a page where all the questions in the DB are shown along with certain data elements from parent object and create a table e.g.:
Proposal Name Proposal Type Question Name Question Text
Normally in an SQL you can get that result with a query like below:
Select proposal_name, proposal_type, question_name, question_text
from proposal, question
where question.proposal_id = proposal.id
But I am not able to get the similar construct that I can use in APEX controller to fetch the desired set of data?
So far I have tried following combinations
[Select Proposals__r.Name, Proposals__r.Client_Name__c, Proposals__r.proposal_type__c, Question__c from Question__c];
Error:
Didn't understand relationship 'Proposals__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name.
2nd Option:
[Select id, name, Client_Name__c, proposal_type__c, (select question__c from Questions__r) from proposals__c];
Result Query worked but not able to access questions data in visualforce page to display.
select name, proposal__r.name from question where proposal__c =: proposalIdVariable