jeudi 21 avril 2016

Android Syntax Error (Code 1) SQLite rawquery problems when adding Where clause

Cant seem to figure out whats wrong with my query statement, according to examples raw query's to sqlite this is how it should look:

Cursor cursor = getReadableDatabase().
rawQuery("select * from todo where _id = ?", new String[] { id });

Ok easy enough, so I am trying to do this:

String query = "SELECT RESULT FROM " + TABLE_NAME + "WHERE " + COL_3 + " = Nitrates ";

or this

String query = "SELECT RESULT FROM " + TABLE_NAME + "WHERE TYPE = Nitrates";

neither work but this works just fine....

String query = "SELECT RESULT FROM " + TABLE_NAME;

so what gives with my where portion of it?

The Error I am getting:

E/AndroidRuntime: FATAL EXCEPTION: main android.database.sqlite.SQLiteException: near "=": syntax error (code 1): , while compiling: SELECT RESULT FROM testData_tableWHERE TYPE = Nitrates

Aucun commentaire:

Enregistrer un commentaire