1

I have 2 queries and I cannot figure out how I can nest them.

I have 3 objects that look to each other in this order: test_result__c looks up to test_process__c which looks up to contact.

Here are my queries:

List<Test_Result__c> activeParticipantsIds = [
    SELECT Test_Process__r.Candidate__c
    FROM Test_Result__c
    WHERE Status__c = 'New'
];

List<Contact> activeCandidates = [
    SELECT Name
    FROM Contact
    WHERE Id = :activeCandidatesIds[0].Interview_Process__r.Candidate__c
];

Do you have any idea how I can merge both queries into one? Thank you.

2

It should look something like this, although I'm not completely sure if it's the right syntax.

List<Contact> activeCandidates = [
    SELECT Name
    FROM Contact
    WHERE Id in: (
    SELECT Test_Process__r.Candidate__c
    FROM Test_Result__c
    WHERE Status__c = 'New' Limit 1)
];
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.