Android : where clause using OR and AND in sqlite android

on Friday, January 30, 2015


I want to match string to any 3 column of the table and 4th column must be equal to some string in the SQlite Database table. For example , lets take 3 columns : first_name,middle_name,last_name either of these columns equal to = "String" and 4th column : age= 20.But below query reruns "null", So please help to solve the problem.



Cursor cursor = db.query(TABLE_ONE, new String[] { KEY_FNAME, KEY_MNAME, KEY_LNAME }, KEY_FNAME + "=? OR " + KEY_MNAME + "=? OR " + KEY_LNAME + "=? AND " + KEY_AGE + "=?",
new String[] { string , string, string, "20"}, null, null, null, null);

0 comments:

Post a Comment