You need to sign in to do that
Don't have an account?
Brendan Walton 2
SOQL - Query Session date from Junction Object
I have the following:
Attempting the following query:
Returns:
I'm not sure what I'm doing wrong. I'm very clearly inserting the __r as the error message suggests. The Session Speaker object clearly has the relationship I'm attempting to utilize. The session object clearly has the date field I'm attempting to query.
Attempting the following query:
SELECT Id,(SELECT Session_Date__c FROM Session__r) FROM Session_Speaker__c
Returns:
Id,(Select Session_Date__c FROM Session__r) FROM Session_Speaker__c
^
ERROR at Row:1:Column:40
Didn't understand relationship 'Session__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
^
ERROR at Row:1:Column:40
Didn't understand relationship 'Session__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
I'm not sure what I'm doing wrong. I'm very clearly inserting the __r as the error message suggests. The Session Speaker object clearly has the relationship I'm attempting to utilize. The session object clearly has the date field I'm attempting to query.
SELECT Id, session__r.Session_Date__c FROM Session_Speaker__c
when you go up, you can use dot notation
thx.
All Answers
SELECT Id, session__r.Session_Date__c FROM Session_Speaker__c
when you go up, you can use dot notation
thx.
As Session speaker is junction, you can't do inner query, use this instead:
SELECT Id, Sessions__r.Session_Date__c FROM Session_Speaker__c
Thanks,
Neetu
So:
Detail to master = Dot notation
Master to detail = Inner query
Correct?
Detail to master (go up to parent) = Dot notation
Master to detail (go down to child) = Inner query (using the child relationship name, which you define which usual includes an 's')
Thx
SELECT Id, (SELECT Id FROM Session_Speaker__r) FROM Session__c
Use plural name like:
SELECT Id, (SELECT Id FROM Session_Speakers__r) FROM Session__c
Thanks,
Neetu
I tried that as well:
SELECT Id, (SELECT Id FROM Session_Speakers__r) FROM Session__c
Returns the same error message
Thanks,
Neetu
SELECT Id, (SELECT Id FROM Session_Speakers__r) FROM Session__c
assuming that's the child relationship name you gave it:
Go to the session object and verify:
Master-Detail Options
Related To Session Child Relationship Name Session_Speakers
It was the Child relationship name on the Session_Speakers object that had the same type from the Plural name on the same object.
Thanks William/Neetu you guys have been extremely helpful.
For the best anwer, I'm going to pick the one that most directly answered my original post; however, since you both posted the same answer, I'm going to pick the first person to post it. I feel that's the fairest way; however, I'd like to restate, you were both very helpful. Thank you so much.