I need to make two left joins on two tables. My tables are basically as follows:
MAIN:
category id, product name, producer name
CATEGORY
category id, supercategoryid, name
SUPERCATEGORY
supercategoryid, name.
I need to get all the rows in MAIN along with the category name and supercategory name.
Can anyone tell me how to do this? I started with getting the main info and category info, but it only returns 5 results where the category ID is 1:
Code:
String selection = null;
Cursor peopleCursor = doSearch(MAIN_TABLE, new String[] { "category_id", "product",
"producer" }, selection, "category_id ASC");
Cursor siCursor = doSearch(CATEGORY_TABLE, new String[] { "id", "name" },
selection, "id ASC");
CursorJoiner joiner = new CursorJoiner(
peopleCursor,
new String[] { "category_id" },
siCursor,
new String[]
{"id"});
MatrixCursor cursor = new MatrixCursor( new String[]
{"name","product","producer"});
for (CursorJoiner.Result joinerResult : joiner) {
switch (joinerResult) {
case BOTH:
//prints out info here
break;
}
}
Is there an easier way to do this?