Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible use nested SUBQUERY in NSPredicate?

As you can see I have two one-many relationships. Is it possible to write such a nested SUBQUERY where I want to select all A, where any of the belonging C-s under any of belonging B to A satisfy a certain condition?

enter image description here

like image 762
János Avatar asked Nov 05 '12 00:11

János


1 Answers

You can nest SUBQUERY in a predicate. But it seems that a single SUBQUERY is sufficient here (if ds is a to-one relationship from C to D), for example

[NSPredicate predicateWithFormat:@"SUBQUERY(bs, $x, ANY $x.cs.ds.name = %@).@count > 0", name];
like image 149
Martin R Avatar answered Sep 27 '22 22:09

Martin R