Mam 2 tabele w mojej bazie danych, na przykład: Table1: id (PK), data1
i Table2: id (PK), id_table1 (FK), data2
. Jak mogę złożyć zapytanie tak:Zapytanie SQLite z wielu tabel przy użyciu SQLiteDatabase
SELECT * FROM Table1, Table2 WHERE Table1.id = Table2.id_table1
GROUP BY Table1.data1
Używam SQLiteDatabase
i jego metody query()
.
Cursor mCursor = db.query(true, new String[] {"Table1","Table2"},
new String[] {"Table1.id","data1", "Table2.id", "id_table1", "data2"},
"Table1.id=Table2.id_table1", null, "Table1.data1", null,null,null);
Ale jest problem z drugim arg - jest to możliwe tylko do korzystania z ciągiem, nie String [] (jak new String[] {"Table1","Table2}
). Co powinienem zrobić, aby w ten sposób utworzyć zapytanie z wielu tabel?
@Graham jak przekazać id w ten –