function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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'];