0

Trying to get a query but doesn't seem to work.It gives out this error:

android.database.sqlite.SQLiteException: no such column: Gravity (code 1): , while compiling: SELECT club_id FROM Club WHERE club_name like Gravity

This is the code:

private String getClubCode(String clubName){
        open();
        Cursor mCursor = myDb.rawQuery("SELECT " + Table.Club.ID + " FROM " + Table.Club.TABLE_NAME + " WHERE " + Table.Club.NAME + " like " + clubName , null);
        close();

        return mCursor.getString(mCursor.getColumnIndex(Table.Club.ID));
    }

1 Answer 1

1

Put Extra ' before and after clubName:

Cursor mCursor = myDb.rawQuery("SELECT " + Table.Club.ID + " FROM " + Table.Club.TABLE_NAME + " WHERE " + Table.Club.NAME + " like '"+ clubName + "'" , null);
Sign up to request clarification or add additional context in comments.

1 Comment

Even better, you could use a bound parameter.

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.