suyash saurabh suyash saurabh - 3 years ago 187
Android Question

android sqlite database error in using where clause in comparing things

i am getting this error please help-


android.database.sqlite.SQLiteException: near "=": syntax error (code
1): , while compiling: SELECT SUM( amountinserted ) FROM
mbudgettablewheredatename='30-09-2017'


CODE:

Cursor cursor = db.rawQuery("SELECT SUM( " +amountinserted + " ) " +
"FROM " +tablename + "where" +datename + "='" + rmethod() + "'", null);

Answer Source

You should write the code like the below code: Cursor cursor = db.rawQuery("SELECT SUM( " +amountinserted + " ) " + " FROM " +tablename + " where " +datename + "='" + rmethod() + "'", null);

You are missing white space before "FROM" and "where" in the query

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download