0

Given Account - MaintenancePlan relationship, I have this SOQL:

SELECT Id, (SELECT id from MaintenancePlans WHERE Id = 'xxxxxxxxpUGAS') FROM Account

Problem is that I just need to get the MaintenacePlans which Id is specified in query, but I get all Accounts of my ORG. So, I need to make a query that just get MaintenancePlan with the ID 'xxxxxxxxpUGAS'.

1 Answer 1

1

You need to add a where clause in SOQL for Account and use join to filter account record, example:

 SELECT 
    Id, 
    (SELECT id from MaintenancePlans WHERE Id = 'xxxxxxxxpUGAS') 
    FROM Account WHERE
    Id IN (SELECT Account__c from MaintenancePlan WHERE Id = 'xxxxxxxxpUGAS')

// Here I assume, Account__c  is field API name and MaintenancePlan  is SObject API Name
1
  • You are the best man!! Thank you!
    – CPS
    Dec 27, 2021 at 12:27

You must log in to answer this question.

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