这是关于Parse后端的。
我有两张桌子:
事件: objectId,联系人,标题,latlng,noi,ACL,父级,用户(指向用户的指针),data_to,精选,weblink,updatedAt,组织(指向组织的指针),地址, emailid,tags,major,rsvp(boolean),createdAt,image,date_from,description,is_major_event,group(指向Group的指针)
Event_stat: objectId,ACL,createdAt,event(指向Event的指针),rsvp(join / maybe / seen),updatedAt,user(指向User的指针)
我想加入这些表,结果表将用于查询:
从[join result]中选择*,其中event_stat_user =“asdcvb”AND organization =“abc”AND(event_stat_rsvp =“join”或rsvp =“maybe”)sortby event_stat_updatedAt
任何人都可以帮助我如何在Android中实现这一目标?
答案 0 :(得分:1)
我找到了一种创建子查询的方法:
ParseQuery<ParseObject> query = new ParseQuery("event_stats");
query.setLimit(1000);
query.whereEqualTo("user", ParseUser.getCurrentUser());
ParseQuery<ParseObject> parseInnerQuery = new ParseQuery<>("event");
parseInnerQuery.whereEqualTo("organization", ParseObject.createWithoutData("organization", Data.getValue(OrganizeActivity.CURRENT_ORGANIZATION)));
query.whereMatchesQuery("event", parseInnerQuery);
query.include("event");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
if (e == null && list != null && list.size() != 0) {
List<Event> listEvent = new ArrayList<Event>();
for (ParseObject parseObject : list) {
listEvent.add(Event.getEventById(getValue(parseObject, "event")));
}
masterEventAdapter.setEvents(listEvent);
} else {
}
}
});