+ Start a Discussion
viktorVviktorV 

SOQL Relationship query

Hi,

I'd like to create a query, but always get malformed query error: Didn't understand relationship Activity__c.Lead__r in FROm part of query call

Activity is a custom object, with a foregn key to Leads.

 

 

SELECT 
Activity__c.Name, 
Activity__c.Id, 
Activity__c.Lead__c, 
(SELECT Lead__r.Status, Lead__r.CreatedDate, Lead__r.OwnerId, Lead__r.Country__r FROM Activity__c.Lead__r) 
FROM 
Activity__c 
WHERE 
 Name = 'xxx'

 

 

What would be the right syntax?

 

Thank you,

Viktor

Bhawani SharmaBhawani Sharma

List<Lead> lsitLead = [Select Id,(Select Id fromOpenActivities) from Lead where Name = 'xxx'];