Reputation: 123
I have a data(name) that is coming from two seperate table coming one at a time in sqlite in android..and i have to get all the record on the basis of that data(name)..
I tried the following query but it didn't work.
String selectQuery = "SELECT " +
GlobalConstants.EM_DESCRIPTION+ " , " +
GlobalConstants.EM_TOTAL_AMOUNT +
" FROM " +
GlobalConstants.INCOME_MANAGER_TABLE_NAME+"," +
GlobalConstants.EXPENSE_MANAGER_TABLE_NAME+
" WHERE " +
" nameof_customer "+" = "+" '"+get_Name+"'";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
then what query should i use
Upvotes: 1
Views: 451
Reputation: 52800
Can you please try below one ?
Cursor c = db.rawQuery("SELECT * FROM Your_Table_Name WHERE nameof_customer = '"+name.trim()+"'", null);
Hopew this would help you.
Upvotes: 0
Reputation: 777
You should use getReadableDatabase() method instead of getWritableDatabase() and check your fields name in the select query.
Upvotes: 2