Select id,name,phone,email,CampaignMember 
from lead 
where CampaignMember=:selectedcampaign


No such column 'CampaignMember' on entity 'Lead'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

Please help me to modify this.

  • here "selectedcampaign" is campaign id
    – SFDC V
    Apr 8, 2019 at 11:08
  • What is the condition that you are trying to form here and fetch the lead records?
    – Jayant Das
    Apr 8, 2019 at 13:27

2 Answers 2


You can use select Id, Name, Phone, Email from Lead where Id in (select LeadId from CampaignMember where CampaignId = :selectedcampaign)


If you want to get lead details which is part of a campaign then you will have to query CampaignMember records first where LeadId is matching and then do another query on lead based on the found lead Ids.

Set<Id> lstLeadIds = new Set<Id>();
for(CampaignMember cm : [SELECT LeadId FROM CampaignMember WHERE CampaignId =:campaignId ) {

//Query lead records 
List<Lead> lstLeads = [SELECT Id, Name, Phone, Email FROM Lead WHERE Id IN :lstLeadIds];

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .