Reputation: 27
Please find what is wrong here
here _id and chek is the column of my db i to write a query to search those which has id =id and check =number
public Cursor query(int id){
return myDataBase.query("question", null,"_id = "+id+ "AND " + "chek ="+number,null, null, null, null);
}
Upvotes: 0
Views: 450
Reputation: 478
Replace your query with these lines if not yet solved..
public Cursor query(int id){
return myDataBase.query("question", null,"(_id = "+id+ " AND " + "chek ="+number+")",null, null, null, null);
Upvotes: 0
Reputation: 3215
May this help you:
Replace your query with these lines..
public Cursor query(int id){
return myDataBase.query("question", null,"_id = "+id+ " AND " + "chek ="+number,null, null, null, null);
keep space between the double quotes in And :" And "
otherwise the string will be
Example: _id=3And check =9
Upvotes: 1
Reputation: 14199
try
return myDataBase.query("question", null,"_id = "+id+ " AND " + "chek ="+number,null, null, null, null);
Upvotes: 0
Reputation: 4114
Firstly check your sql query syntax are right or not
You can use raw query
String SQL= "select * from question where _id = "+id+ " and chek ="+number+";
Log.d("SQL::", SQL);
Cursor cursor = db.rawQuery(SQL, null);
Upvotes: 0