android.database.sqlite.SQLiteException:没有这样的列:

时间:2015-11-15 18:21:28

标签: android sqlite

尝试获取查询但似乎无效。它发出此错误:

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

这是代码:

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 个答案:

答案 0 :(得分:1)

在clubName之前和之后加上额外'

Cursor mCursor = myDb.rawQuery("SELECT " + Table.Club.ID + " FROM " + Table.Club.TABLE_NAME + " WHERE " + Table.Club.NAME + " like '"+ clubName + "'" , null);