0

I have a query with several constraints:

ParseQuery < ParseObject > requestsQuery = ParseQuery.getQuery(ParseConstantsUtil.CLASS_REQUEST);
requestsQuery.whereContains(ParseConstantsUtil.REQUEST_AUTHOR, currentUser.getObjectId());
requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_STATUS, "Approved");
requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_STATUS, "Rejected");
requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_READ, false);
try {
 List < ParseObject > requestsList = requestsQuery.find();
 return listSize(model, requestsList);
} catch (ParseException e) {
 e.printStackTrace();
}

One of those constraints happens to be related to the same column in my database:

requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_STATUS, "Approved");
requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_STATUS, "Rejected");

The above does not seem to work. How can I do an OR query for the same database column using ParseQuery?

requestsQuery.whereEqualTo(ParseConstantsUtil.REQUEST_STATUS, "Rejected" || "Approved");
Martin Erlic
  • 5,467
  • 22
  • 81
  • 153
  • Possible duplicate of [Multiple Combined "Or" Queries using Android Parse](http://stackoverflow.com/questions/28892973/multiple-combined-or-queries-using-android-parse) – john16384 Apr 04 '17 at 13:07

1 Answers1

1

Use ParseQuery#whereContainedIn:

List<String> vals = new ArrayList<>();
vals.add("Rejected");
vals.add("Approved");
requestsQuery.whereContainedIn((ParseConstantsUtil.REQUEST_STATUS, vals);

See api documentation for more information.

dpoetzsch
  • 757
  • 1
  • 7
  • 19