尝试获取查询但似乎无效。它发出此错误:
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));
}
答案 0 :(得分:1)
在clubName之前和之后加上额外' :
Cursor mCursor = myDb.rawQuery("SELECT " + Table.Club.ID + " FROM " + Table.Club.TABLE_NAME + " WHERE " + Table.Club.NAME + " like '"+ clubName + "'" , null);