具有多个位置的android sqlite查询

标签 android sqlite

这是我当前的 sqlite 代码:

Cursor c = sqlDatabase.rawQuery("select docid as _id, recipeID from " + TABLE_RECIPE_NAME + 
                " where " + KEY_ownerID + " = ? ", new String[] { ownerID});

它工作正常,但是当我尝试向这样的内容添加多个位置时:

Cursor c = sqlDatabase.rawQuery("select docid as _id, recipeID from " + TABLE_RECIPE_NAME + 
                " where " + KEY_ownerID + " = ?, " + KEY_partnerID + " = ?, " + KEY_advertiserID + " = ?, " + KEY_chefID + " = ?", new String[] { ownerID, partnerID, advertiserID, chefID });

它返回一个错误。那么如何处理多个呢?

最佳答案

将查询更改为:

Cursor c = sqlDatabase.rawQuery("select docid as _id, recipeID from " +
TABLE_RECIPE_NAME + " where " + KEY_ownerID + " = ? AND " + KEY_partnerID +
" = ? AND  " + KEY_advertiserID + " = ? AND " + KEY_chefID + " = ?",
new String[] { ownerID, partnerID, advertiserID, chefID });

关于具有多个位置的android sqlite查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9061410/

相关文章:

android - Android "Active Installs"中的 "Developer Console"计数/百分比是怎么计算出来的?

sql - SQLITE3子查询

php - 在长时间的过程中连接丢失以在数据库 sqlite3 codeigniter 中保存记录

java - 我无法将数据插入我的数据库

android - 在 RecyclerView 中自动调整 TextViews 会导致文本大小减小

android - EditText 在我键入时停止显示字符?

android - 使用 Android 语音识别 API

多次sqlite查询对比

android - 在 sqlite 查询中如何获取具有所需值的特定行和列

android - 如何从 android 中的 firebase 获取子值的子值?