如何将搜索where子句中两列 [英] how to include both columns in where clause for searching

查看:154
本文介绍了如何将搜索where子句中两列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从以下两种表列的搜索我的数据,但以下code不工作我该怎么办?

 光标C = queryBuilder.query(ourHelper.getReadableDatabase()
新的String [] {_ID,SearchManager.SUGGEST_COLUMN_TEXT_1,SearchManager.SUGGEST_COLUMN_TEXT_2,SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID},KEY_ADDRESS +怎么样?+或+ KEY_ROWID +怎么样?,selectionArgs两个,NULL,NULL,KEY_ADDRESS +ASC ,10);


解决方案

兄弟,很容易....我希望它会为你的工作where子句

 字符串,其中= KEY_ADDRESS +=+变量+和+ KEY_ROWID +='+ var_id +';
光标C = mDb.query(真,TABLE_MENUS,新的String [] {您的列名},其中,NULL,NULL,NULL,NULL,NULL);

I want to search my data from either of two table columns but the following code is not working what can I do ???

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");

解决方案

Bro, it is easy .... I hope it will work for your where clause

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);

这篇关于如何将搜索where子句中两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆