1

I'm getting the following error while compiling a SELECT query:

Caused by: android.database.sqlite.SQLiteException: near "group": syntax error (code 1): , while compiling: SELECT group_id, logo FROM group WHERE group_name = 'Empty Group'

The query is created as:

c = database.query(TABLE_GROUP, new String[]{KEY_GROUPID, KEY_LOGO}, KEY_GROUPNAME + " = '" + description + "'", null, null, null, null);

with:

TABLE_GROUP = "group";
KEY_LOGO = "logo";
KEY_GROUPID = "group_id";

and the creation script for the table:

create table group 
(group_id integer primary key autoincrement, 
group_name text not null, 
logo string);

Anyone knows what's wrong?

2
  • make sure you have created group table in db Commented Oct 4, 2015 at 12:42
  • make sure 'group' is not a keyword. change table's name to something else then check Commented Oct 4, 2015 at 12:44

1 Answer 1

2

group is a SQLITE keyword and, as every reserved words, it can't use it as table/column name. To fix chose another name for your column. You can find a list of the SQLITE reserved keywords here

Sign up to request clarification or add additional context in comments.

1 Comment

You're completely right. I completely forgot that "group by" can be used in SQL. I needed someone to remember me! Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.