Built-in Android SQLite, I write a small application that should implement a search for one field on the principle of LIKE, and return another field for the found records.

android.database.sqlite.SQLiteException: no such column: тен (code 1): , while compiling: SELECT gruppe FROM drugs WHERE drugname LIKE тен 

"ten" is the desired line, "gruppe" - the returned field, "drugname" - the field by which the comparison is made "drugs" - the table The application is assembled, compiled (0 warnings 0 errors) falls with the above executor. I will be glad to any help. Below is the request execution code:

 database = dbHelper.getWritableDatabase(); String stQuery = "SELECT " + DBHelper.KEY_GROUP + " FROM " + DBHelper.TABLE_NAME + " WHERE " + DBHelper.KEY_NAME + " LIKE "+ editText.getText().toString(); Cursor cursor = database.rawQuery(stQuery, null); if (cursor.moveToFirst()) { int groupIndex = cursor.getColumnIndex(DBHelper.KEY_GROUP); do { stGroup = cursor.getString(groupIndex); } while (cursor.moveToNext()); } cursor.close(); 
  • You forgot quotes: select group from tab where key like '%тен%' - Yura Ivanov

1 answer 1

You can try to redo the request. Try this

  Cursor cursor = sqLiteDatabase.query(DBHelper.TABLE_NAME, new String[]{DBHelper.KEY_GROUP}, DBHelper.KEY_NAME + " LIKE ", new String[]{editText.getText().toString()}, null, null, null);