How would I write a query that selects where the selection is IN the column? I've only seen it where the column is in the selection like this:
String[] names = { "name1", "name2" }; // do whatever is needed first
String query = "SELECT * FROM table"
+ " WHERE name IN (" + makePlaceholders(names.length) + ")";
Cursor cursor = mDb.rawQuery(query, names);
I basically want the opposite of this. My app is a recipe finding app so there is one column that has a string of ingredients for every entry. I want to be able to select the recipe where the input selection (let's say "chicken rice") was in the string of ingredients ("chicken rice onions...").
Is it possible to do this?
this is what my query looks like now
mCursor = mDb.query(true, SQLITE_TABLE, new String[] {COLUMN_ROWID,
COLUMN_NAME, COLUMN_TYPE, COLUMN_INGRED, COLUMN_SPECIAL, COLUMN_DESCRIPT, COLUMN_ALLINGRED, COLUMN_INSTRUCT, COLUMN_IMGPATH},
COLUMN_ALLINGRED + " in '%" + inputText + "%'",
null, null, null, null, null);
Aucun commentaire:
Enregistrer un commentaire