我想做类似以下的事情:
Cursor mCursor = db.rawQuery("SELECT * FROM Table1, Table2 " +
"WHERE Table1.id = Table2.id_table1 " +
"GROUP BY Table1.data1", null);
是否可以使用两个不同数据库中的表格来执行相同操作?
答案 0 :(得分:2)
首先只需attach另一个数据库:
db.execSQL("ATTACH '/path/to/other.db' AS otherDB");
db.rawQuery("SELECT * FROM Table1, otherDB.Table2 " +
"WHERE Table1.id = otherDB.Table2.id_table1 " +
"GROUP BY Table1.data1", null);