.SQLiteException: near ",": syntax error (code 1): , while compiling:
21,749
Rename or quote the check
column since check
is a keyword in SQL.
For example:
private static final String DATABASE_CREATE =
"CREATE TABLE if not exists " + SQLITE_TABLE + " (" +
KEY_ROWID + " integer PRIMARY KEY autoincrement," +
KEY_CURSUS + "," +
KEY_ONDERDEEL + "," +
KEY_GAME + "," +
KEY_TIJD + "," +
KEY_WEB + "," +
+ "`" + KEY_CHECK + "`," +
" UNIQUE (" + KEY_ROWID +"));";
Author by
user2378812
Updated on July 09, 2022Comments
-
user2378812 almost 2 years
What am I missing? Something with a "," but I seem to be looking in the wrong place. This is my code:
private static final String DATABASE_CREATE = "CREATE TABLE if not exists " + SQLITE_TABLE + " (" + KEY_ROWID + " integer PRIMARY KEY autoincrement," + KEY_CURSUS + "," + KEY_ONDERDEEL + "," + KEY_GAME + "," + KEY_TIJD + "," + KEY_WEB + "," + KEY_CHECK + "," + " UNIQUE (" + KEY_ROWID +"));";
And this is the error I get:
Caused by: android.database.sqlite.SQLiteException: near ",": syntax error (code 1): , while compiling: CREATE TABLE if not exists Games_getset (_id integer PRIMARY KEY autoincrement,cursus,onderdeel,game,tijd,web,check, UNIQUE (_id));
-
Miguel Maciel about 10 yearsLook here: stackoverflow.com/questions/18718178/…
-
-
laalto about 10 yearsThis isn't the issue - it's all right to have columns with just the name specified. The problem is using a reserved word
check
as a column name which confuses the SQL parser. -
user2378812 about 10 yearsThanks laalto (and CRUSADER)!
-
anoo_radha over 7 yearsI made the same mistake by naming a column as 'cast'. I realized the mistake after reading your answer. Thanks
-
Al Lelopath over 7 yearsSame problem for me except my column name was 'group'