How to make this line work?
return ourDatabase.rawQuery("SELECT * FROM GL_" + tablename + " WHERE " + KEY_GROUP_T + " = " + grp + " ORDER BY " + KEY_NAME_T + " COLLATE NOCASE", null);
04-23 17:58:26.701: E/AndroidRuntime(9212): Caused by:
android.database.sqlite.SQLiteException: no such column: Baked_Goods:
, while compiling: SELECT * FROM GL_table4 WHERE grlist_group =
Baked_Goods ORDER BY grlist_name COLLATE NOCASE
This line is working but I want to do it with rawQuery:
return ourDatabase.query("GL_" + tablename, columns, KEY_GROUP_T + "= ?" , new String[]{grp}, null, null, null);
To make this work, you have to put single-quotes around your strings. Example:
Addition
Waqas has a good point if
grpis taken from the user’s input, he is preventing a SQL insertion attack. If you always definegrp, then it isn’t critical but good practice.