You need to sign in to do that
Don't have an account?
bakum
understanding relationship queries
Hi,
I have a custom object, Logistics_Event__c, which has a field which is a lookup to another custom object, Course__c. (I'm doing this with the PHP toolkit, by the way)
I want to query my Logistics Events and return fields from Course__c: Name and Version__c.
I've tried two ways with no luck:
SELECT
l.Id,
l.Start_Date__c,
l.Number_of_Days__c,
l.Location__c,
Course__r.Name,
Course__r.Version__c
FROM Logistics_Event__c l
Gives me no error, but doesn't return any info. There is not ALWAYS a course ID on the Logistics_Event__c record, but there is about 50% of the time. I would have thought it would return nothing sometimes and the field data when there's data to return.
I also tried this way:
SELECT
l.Id,
l.Start_Date__c,
l.Number_of_Days__c,
l.Location__c,
(SELECT Name, Version__c FROM Course__c)
FROM Logistics_Event__c l
ERROR: Didn't understand relationship 'Course__c' in FROM part of query call
Can someone illuminate me?
Thanks!
-mb
I have a custom object, Logistics_Event__c, which has a field which is a lookup to another custom object, Course__c. (I'm doing this with the PHP toolkit, by the way)
I want to query my Logistics Events and return fields from Course__c: Name and Version__c.
I've tried two ways with no luck:
SELECT
l.Id,
l.Start_Date__c,
l.Number_of_Days__c,
l.Location__c,
Course__r.Name,
Course__r.Version__c
FROM Logistics_Event__c l
Gives me no error, but doesn't return any info. There is not ALWAYS a course ID on the Logistics_Event__c record, but there is about 50% of the time. I would have thought it would return nothing sometimes and the field data when there's data to return.
I also tried this way:
SELECT
l.Id,
l.Start_Date__c,
l.Number_of_Days__c,
l.Location__c,
(SELECT Name, Version__c FROM Course__c)
FROM Logistics_Event__c l
ERROR: Didn't understand relationship 'Course__c' in FROM part of query call
Can someone illuminate me?
Thanks!
-mb
Did you try child relationships ?
Something like this : select Name, Version, (Select Start_Date__c, Location__c from Logistics_Event__c) from Course__c
This should retrieve Courses, even if there is no Logistics Events associated.