I want to provide a query to my database that will search if a string exists in Column1 OR in Column2 AND only display it if another String value exists in Column3.
This my working code for searching in 2 columns :
mCursor = db.query(true, DATABASE_TABLE, new String[] {KEY_ROWID,
KEY_TIME, KEY_TITLE, KEY_COLOR, KEY_BODY},
KEY_BODY + " like '%" + inputText + "%' OR " + KEY_TITLE + " like '%" + inputText + "%'" , null,
null, null, KEY_TIME + " DESC", null);
I cannot figure out how to add the third column to the Search though.
I tried this :
mCursor = db.query(true, DATABASE_TABLE, new String[] {KEY_ROWID,
KEY_TIME, KEY_TITLE, KEY_COLOR, KEY_BODY},
KEY_BODY + " like '%" + inputText + "%' OR " + KEY_TITLE + " like '%" + inputText + "%' AND " + KEY_COLOR + "like '%" + colorvalue + "%'" , null,
null, null, KEY_TIME + " DESC", null);
but the AND only applies to the "TITLE" column not both. I've searched around the web but i couldn't figure it out.
Your help would be appreciated!