如何在where子句中包含两个列进行搜索

时间:2014-03-20 16:38:27

标签: android sqlite

我想从两个表列中的任何一个列中搜索我的数据但是以下代码无法正常工作我该怎么办?

Cursor c = queryBuilder.query(ourHelper.getReadableDatabase(),                  
new String[] { "_ID", SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_TEXT_2, SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID }, KEY_ADDRESS + " like ? " + " OR " + KEY_ROWID + " like ? ", selectionArgs, null, null, KEY_ADDRESS + " asc ", "10");

1 个答案:

答案 0 :(得分:0)

兄弟,这很容易......我希望它适用于你的where子句

String where = KEY_ADDRESS  + "=" + variable + " and " + KEY_ROWID  + "='" + var_id + "'";
Cursor c = mDb.query(true, TABLE_MENUS, new String[] { your column name}, where, null, null, null, null, null);