Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.SQLiteException: near ",": syntax error (code 1): , while compiling:

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));
like image 205
user2378812 Avatar asked Mar 26 '26 13:03

user2378812


1 Answers

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 +"));";
like image 100
laalto Avatar answered Mar 29 '26 04:03

laalto