Mihai Bratulescu
Mihai Bratulescu

Reputation: 1945

Android database useing multiple like statements

I am making a search function and I need to search using two inputs:

  1. the category id (CID) it is a string that is contained (or not) in KEY_P_CAT_LIST (it cant be done with = as it usually isn't equal)

  2. the search text input (input)

I need to check if the category and the input text is contained in the db record and return it in a cursor if so.

coloane is correctly defined as a [] String and is not the problem.

My atempt:

db.query(true, P_TABLE, coloane,KEY_P_CAT_LIST + " LIKE " + " AND " +CID + " LIKE", new String[] {"%"+CID+"%", "%"+input+"%"}, null, null, null, null);

Upvotes: 0

Views: 946

Answers (1)

Armaan Stranger
Armaan Stranger

Reputation: 3130

Try this:

db.query(true, P_TABLE, coloane,KEY_P_CAT_LIST + " LIKE ?" + " AND " +CID + " LIKE ?", new String[] {"%"+CID+"%", "%"+input+"%"}, null, null, null, null);

Hope it Helps!!

Upvotes: 1

Related Questions