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
ravi teja 81ravi teja 81 

problem in query

hi iam new to salesforce. i have 3 objects (position,candidates,jobapplications) for jobapplications there are two lookups position and candidates
i want a query to select email and name from candidates for a particular position for ex
  if position name is salesforce developer i need candidates email and number who applied for that position .the relation is given in jobapplication ie in my jobapplication i have given two lookups one for position and one for candidate.please help me how to extract the email.
Swayam  AroraSwayam Arora
List<jobapplications> ja = [Select Id, Candidate__r.Email, Candidate__r.Name from jobapplications where Position__r.Name = 'Salesforce Developer'];

For a single Position there can be multiple job applications, so list of job applications will be returned. In a child object you can query parent object's fields so you will get candidate's email and name for all the job applications.

Please close the thread marking this answer as Best Answer if it really helped. Closing the thread help others finding the correct answer.
ravi teja 81ravi teja 81
hi
thanks for your suggestion but iam getting following error 
Error: Compile Error: Didn't understand relationship 'position__c' in field path. 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. at line 16 column 13


i have written query like this (a = [select Candidate__r.Email__c, Candidate__r.Name from job_application__c 
         where position__r.id = :ApexPages.currentPage().getParameters().get('id')];)