How to get data from multiple tables / classes Parse.com
I have two tables (classes):
StudentInformation: with columns RollNumber, address, name, school StudentMarks: with columns RollNumber, Marks1, Marks2, Marks3
I was able to save data from one form to these two at the same time, but without getting any hints on how to put the query when searching in a list or any other view, something like
'return rows (from both tables together) where number of rolls = 1234' / 'returns rows (from both tables together) where Marks2> 50'
I am using Parse.com server for Android Please help Thanks
source to share
First, the display UI on the ListView is provided by the ParseQueryAdapter. https://parse.com/docs/android_guide#ui-queryadapter
As far as the query goes, I don't think you can join the tables the way you want. Instead, you can create a pointer in StudentMarks for StudentInformation.
Then you can request something like:
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
The following will be available in StudentInformation results:
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
Alternatively, you can also keep the StudentMarks to StudentInformation relationship, just so you know that this is also an option, although I don't feel it suits your current needs as well as the solution above.
source to share