gpt4 book ai didi

java - ANDing,嵌套查询解析服务器android

转载 作者:行者123 更新时间:2023-11-30 02:04:51 24 4
gpt4 key购买 nike

我试图从解析服务器获取一个或多个具有特定年龄、来自特定城市和特定性别的用户,但此代码返回所有年龄为“20”、城市为“纽约”的用户, 性别=“女性”

public void sendQuery() {
String ages1 = SharedPrefsActivity.n;
String cities = SharedPrefsActivity.ph;
String genders = SharedPrefsActivity.e;
ParseQuery<ParseObject> ages =ParseQuery.getQuery("UserImages");
ages.whereEqualTo("age", ages1 );

ParseQuery<ParseObject> city1 = ParseQuery.getQuery("UserImages");
city1.whereMatchesKeyInQuery("city", cities , ages);

final ParseQuery<ParseObject> gender1 = ParseQuery.getQuery("UserImages");
gender1.whereMatchesKeyInQuery("gender", genders, city1);

gender1.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> results, ParseException e) {
for (ParseObject gender : results) {
Object name = gender.get("name");
ParseFile image = (ParseFile) gender.get("ImageFile");
Usernames.add(((Object) name).toString());
imageUrls.add(((ParseFile) image).getUrl().toString());

}

}
});

}

最佳答案

AND 是通过将多个条件应用于单个查询来实现的:

ParseQuery<ParseObject> query =ParseQuery.getQuery("UserImages");

query.whereEqualTo("age", ages1 );
query.whereEqualTo("city", cities );
query.whereEqualTo("gender", genders );

query.findInBackground( ...

关于java - ANDing,嵌套查询解析服务器android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30845121/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com