这是我当前的 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/