Reputation: 13588
I have two tables in my database table1, table2. I have a join query like this:
select a.*,b.* from table1 a,table2 b where a.field1=b.field1;
Its working fine while i test it in sqlite manager(sqlite browser). when i try to make it through java like this:
database.execSQL("select a.*,b.* from table1 a,table2 b where a.field1=b.field1;");
its saying return type
is not cursor
. How can i get it to cursor with join. I have to get that data and show in a listview
Upvotes: 1
Views: 2871
Reputation: 4330
SQLiteDatabase.rawQuery(query, selectionArgs)
Use rawQuery method to design any sort of complex query you might need. In the reference there are many useful methods you might need.
Upvotes: 0
Reputation: 6010
Following is an Example of rawQuery, you can add your Query Respectively.
String getRT = "SELECT count(*) from "+ DATABASE_PROFILE+";";
Cursor mCur = sqlitedb.rawQuery(getRT, null);
return mCur;
Upvotes: 0
Reputation: 2530
use like this:
String qry = "select a.*,b.* from table1 a,table2 b where a.field1=b.field1";
Cursor cur = db.rawQuery(qry,null);
Upvotes: 4
Reputation: 68187
String query = "select a.*,b.* from table1 a,table2 b where a.field1=b.field1;";
Cursor c = database.rawQuery(query, null);
/* do whatever you want with 'c' */
Upvotes: 0