Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

execSQL SQLiteException near "?"

Tags:

android

sqlite

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!!

like image 596
user274959 Avatar asked May 31 '26 00:05

user274959


1 Answers

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.

like image 157
Alex Martelli Avatar answered Jun 02 '26 15:06

Alex Martelli