Reputation: 57
I need to fetch all Departments that don't have an Employee called "Bob"
Based on other answers on SO that I've read, I've tried this:
name = @"Bob";
predicate = [NSPredicate predicateWithFormat:@"ALL employees.name != %@", name];
but it doesn't seem to work. Any ideas?
Thanks.
Upvotes: 2
Views: 2707
Reputation: 540065
Do do not need a subquery here:
name = @"Bob";
predicate = [NSPredicate predicateWithFormat:@"NOT ANY employees.name == %@", name];
For some reason, the "ALL" aggregate does not work with to-many relationships, but the "ANY" aggregate works.
Upvotes: 7