.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 +"));";
Share:
21,749
user2378812
Author by

user2378812

Updated on July 09, 2022

Comments

  • user2378812
    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));
    
  • laalto
    laalto about 10 years
    This 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
    user2378812 about 10 years
    Thanks laalto (and CRUSADER)!
  • anoo_radha
    anoo_radha over 7 years
    I made the same mistake by naming a column as 'cast'. I realized the mistake after reading your answer. Thanks
  • Al Lelopath
    Al Lelopath over 7 years
    Same problem for me except my column name was 'group'