I have two objects, Opportunity(Master) and Rollout(Detail). I am trying to find Id, Name from Opportunity object who have no record in Rollout object. The id field in Rollout is Opportunity__c.
1 Answer
The simplest way would be to create a roll-up summary field on the Opportunity
that counts the Rollout
children, and query for all those where the value of that field is 0. Otherwise:
SELECT Id, Name
FROM Opportunity
WHERE Id NOT IN (SELECT Opportunity__c FROM Rollout__c)
Edit: To be clear, the RUSF would be better because then you don't risk hitting a SOQL Row limit like you would with the compound query.