SQLite equivalent of NSPredicate "ANY array1 IN array2"?

56 Views Asked by At

I'm trying to get started using YapDatabase, mostly to see if it's worth replacing some NSPredicate-based searches I've been using for a while. One search I can't seem to find a good way of doing so far with SQLite queries is finding all objects with where an array property of the object includes any matches with a given search array.

For example, say I have an array of birds, each of which has an array of state names where the bird is found. To search for all birds that are found in a group of states, I would use this predicate filter:

  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY %@ IN foundInStates", arrayOfStates];
  return [_myBirdDatabase filteredArrayUsingPredicate:predicate];

I guess I could make a very convoluted SQLite query involving many "LIKE" operators, but I'm hoping there's a way that's as clean as the NSPredicate search.

0

There are 0 best solutions below