Can't seem to find an example of this.
trigger Opportunity_Triggers on Opportunity (after insert, after update, after delete) {
List<Account> accList = [SELECT Id, (SELECT Id, AccountId FROM Opportunities) FROM Account WHERE Opportunities IN :Trigger.New];
...
}
I want the trigger to fire upon changes to opportunities, but my handler class works with their accounts as well, and I'm trying to minimize my SOQL queries so this can work in bulk.
My issue seems to be with using Opp data pulled from the inner query in the outer query's WHERE clause.
Now, what if I did this:
List<Account> accList = [SELECT Id, (SELECT Id, AccountId FROM Opportunities WHERE Id IN :Trigger.New) FROM Account];
Only the child opps that were triggered would show up... but would that limit the account query to only the parents of those triggered opps?