I have a sqlite query:
rawQuery("select * from ? where ?=?", new String[] {
DBTABLE_PROFILE, KEY_PROFILE_ID, Integer.toString(profileID) });
But Android gives me
E/AndroidRuntime(7323): Caused by: android.database.sqlite.SQLiteException:
near "?": syntax error (code 1): , while compiling: select * from ? where ?=?
I tested which ? was causing problems and it turned out to be the first one. If I change it to
"select * from profile where ?=?"
it doesn’t FC.
SO, can table names be substitued with ‘?’?
[EDIT]:
There is a work-around to achieve rawQuery-like functionality without the limitations. See my answer below.
No. The only parameters that you should be substituted with
?are the query variables, not table names and not column names.The correct query is: