有多个,其中Android的SQLite的查询 [英] android sqlite query with multiple where

查看:126
本文介绍了有多个,其中Android的SQLite的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我当前的SQLite code:

Here's my current sqlite code:

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

它工作正常,但是当我尝试添加多个哪里是这样的:

It works fine, but when I tried adding multiple where to something like this:

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

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

It returns an error. So how do I deal with multiple ?

推荐答案

变更查询:

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的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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