如何从多个Parse.com表/类中检索数据

Lea*_*ays 3 mysql android parse-platform

我有两个表(类):

StudentInformation:使用列RollNumber,地址,名称,学校StudentMarks:包含列RollNumber,Marks1,Marks2,Marks3

我已经能够将单个表单中的数据同时保存到这两个表单中,但是没有得到如何在检索到列表视图或任何其他视图时查询的方式的线索

'返回行(从两个表一起),其中卷号= 1234'/'返回行(从两个表一起),其中Marks2> 50'

我正在使用Parse.com后端Android版帮助谢谢

cYr*_*ten 7

首先,在ListView中显示的UI方面由ParseQueryAdapter提供.https://parse.com/docs/android_guide#ui-queryadapter

关于查询,我认为你不能以你想要的方式连接表.相反,您可以在StudentMarks中创建一个指向StudentInformation的指针.

然后你可以查询类似的东西:

ParseQuery<ParseObject> query = ParseQuery.getQuery("StudentMarks");
query.include('studentInformation'); // include the pointer to get StudentInformation
query.whereEqualTo("RollNumber", 1234);
query.whereGreaterThan("Marks2", 50);
... // perform query
Run Code Online (Sandbox Code Playgroud)

在结果中,StudentInformation将如下所示:

List<ParseObject> objects; // the result from the query
ParseObject studentMark = objects.get(0); // example using first object
ParseObject studentInformation = studentMark.get("studentInformation");
String studentName = studentInformation.get("name");
String studentAddress = studentInformation.get("address");
... // etc
Run Code Online (Sandbox Code Playgroud)

或者你也可以在StudentInformation上存储StudentMarks的关系,只是为了让你知道这也是一个选项,虽然我觉得它不符合你当前的需要以及上面提出的解决方案.