我一直在尝试在表的两个不同字段上对两个条件进行OR运算。虽然个别条件工作正常,但当我尝试同时使用它时,它不起作用。 这是我的代码:
ParseQuery<NewExamAlert> query = ABC.getQuery();
query.whereContainedIn("category", Arrays.asList(arr)); //here arr is array of different category
query.whereContainedIn("subCategory", Arrays.asList(arr1));//here arr1 is array of different subcategory
query.findInBackground(new FindCallback<ABC>() {
public void done(List<ABC> list, ParseException exp) {
//My Logic
}
}
请让我知道,我错过了什么?
答案 0 :(得分:2)
你需要明确地“或”他们:
List<ParseQuery<NewExamAlert>> queries = new ArrayList<ParseQuery<NewExamAlert>>();
queries.add( ParseQuery<NewExamAlert> query1 = ABC.getQuery()
.whereContainedIn("category", Arrays.asList(arr)) );
queries.add( ParseQuery<NewExamAlert> query2 = ABC.getQuery()
.whereContainedIn("subCategory", Arrays.asList(arr1)) );
ParseQuery<NewExamAlert> orQuery = ParseQuery.or( queries );
orQuery.findInBackground(new FindCallback<ABC>() {
public void done(List<ABC> list, ParseException exp) {
//Your Logic
}
}