ydnas
ydnas

Reputation: 519

SQLiteException: near "references": syntax error

String CREATE_ASSIGNMENTS_TABLE= "create table "
        + ASSIGNMENTS + "(" + TITLE
        + " text not null, " + DESCRIPTION
        + " text not null, " + REFERENCES + " text not null );";

This is my create table query to create a table in SQLite.

I have three fields (title,description,reference). All are text fields. But when I execute the code, I get the following Exception:

android.database.sqlite.SQLiteException: near "references": syntax error (code 1): , while compiling: create table ASSIGNMENTS(TITLE text not null, DESCRIPTION text not null, REFERENCES text not null);

It is pointing to an error in the REFERENCES field. But I couldn't find any syntax error there. Please help me out in this matter.

Upvotes: 1

Views: 767

Answers (1)

laalto
laalto

Reputation: 152887

REFERENCES is a keyword in SQL syntax. Either change the column name or quote it in backticks:

`REFERENCES`

Upvotes: 3

Related Questions