Sqlite查询使用具有多个条件的条件来满足

时间:2013-07-23 06:47:00

标签: android mysql sqlite android-sqlite

请找出这里有什么问题

这里_id和chek是我的db i的列,用于编写查询来搜索那些id = id和check = number

的列
 public Cursor query(int id){
    return myDataBase.query("question", null,"_id = "+id+ "AND " +  "chek ="+number,null, null, null, null); 


}

4 个答案:

答案 0 :(得分:1)

这可以帮到你:

用这些行替换您的查询..

public Cursor query(int id){
return myDataBase.query("question", null,"_id = "+id+ " AND " +  "chek ="+number,null, null, null, null);

在And:" And "中的双引号之间保留空格,否则字符串将为示例: _id=3And check =9

答案 1 :(得分:0)

首先检查你的sql查询语法是否正确

您可以使用原始查询

 String SQL= "select * from question where _id = "+id+ " and chek ="+number+";
    Log.d("SQL::", SQL);
    Cursor cursor = db.rawQuery(SQL, null);

答案 2 :(得分:0)

<强>尝试

return myDataBase.query("question", null,"_id = "+id+ " AND " +  "chek ="+number,null, null, null, null); 

答案 3 :(得分:0)

如果尚未解决,请用这些行替换您的查询。

public Cursor query(int id){
return myDataBase.query("question", null,"(_id = "+id+ " AND " +  "chek ="+number+")",null, null, null, null);