Why doesn't this work??
db.execSQL("INSERT INTO PARTIES (PARTY_NAME, PARTY_COUNT) SELECT DISTINCT(PARTY), COUNT(PARTY) FROM ? WHERE (Year=?) GROUP BY PARTY ORDER BY PARTY ASC", new Object[] { "Election", "2004" });
It works perfectly in rawQuery!!
Why doesn't this work??
db.execSQL("INSERT INTO PARTIES (PARTY_NAME, PARTY_COUNT) SELECT DISTINCT(PARTY), COUNT(PARTY) FROM ? WHERE (Year=?) GROUP BY PARTY ORDER BY PARTY ASC", new Object[] { "Election", "2004" });
It works perfectly in rawQuery!!
I don't know what "rawQuery" you're referring to (URL please). I don't know of any SQL engine which allows parameter substitution for metadata such as names of tables and columns -- only values, nor names, are allowed in parameter substitution. SQLite is no exception.
Thanks you're right. The rawQuery function doesn't error when binding a table name, but it doesn't work anyway. ExecSQL errors on binding a table name.