vinix
vinix

Reputation: 31

Is it possible to query two tables from two separate databases in Android?

I would like to do something similar to following:

Cursor mCursor = db.rawQuery("SELECT * FROM Table1, Table2 " +
                             "WHERE Table1.id = Table2.id_table1 " +
                             "GROUP BY Table1.data1", null);

Is it possible to do the same using tables present over two different databases?

Upvotes: 3

Views: 221

Answers (1)

CL.
CL.

Reputation: 180080

Just attach the other database first:

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);

Upvotes: 4

Related Questions