Android SQLite Search with OR , AND, in multiple database columns -
i want provide query database search if string exists in column1 or in column2 , display if string value exists in column3.
this working code searching in 2 columns :
mcursor = db.query(true, database_table, new string[] {key_rowid, key_time, key_title, key_color, key_body}, key_body + " '%" + inputtext + "%' or " + key_title + " '%" + inputtext + "%'" , null, null, null, key_time + " desc", null); i cannot figure out how add third column search though.
i tried :
mcursor = db.query(true, database_table, new string[] {key_rowid, key_time, key_title, key_color, key_body}, key_body + " '%" + inputtext + "%' or " + key_title + " '%" + inputtext + "%' , " + key_color + "like '%" + colorvalue + "%'" , null, null, null, key_time + " desc", null); but , applies "title" column not both. i've searched around web couldn't figure out.
your appreciated!
you need use brackets this.
mcursor = db.query(true, database_table, new string[] {key_rowid, key_time, key_title, key_color, key_body}, "(" + key_body + " '%" + inputtext + "%' or " + key_title + " '%" + inputtext + "%') , (" + key_color + " '%" + colorvalue + "%')" , null, null, null, key_time + " desc", null); hope helps.
Comments
Post a Comment