Zahid Habib
Zahid Habib

Reputation: 715

Android SQLite Query Not Working

I'm trying to search data on database based on 2 conditions (entryId=rowId & category=cat_id) like below

Cursor mCursor = db.query(true, "favorite", new String[] {"_id", "entry"}, "entryId="+ rowId + "& category="+cat_id, null, null, null, null, null);

Its not working. But when I try to do it using only one condition like below then it works well.

Cursor mCursor = db.query(true, "favorite", new String[] {"_id", "entry"}, "entryId="+ rowId, null, null, null, null, null);

Can you help me telling how can I run this query with multiple conditions?

Upvotes: 0

Views: 589

Answers (1)

Sam
Sam

Reputation: 86958

In SQLite & is different from AND, simply use:

Cursor mCursor = db.query(true, "favorite", new String[] {"_id", "entry"}, 
        "entryId="+ rowId + " AND category="+cat_id, null, null, null, null, null);
// Change & to AND...  here:  ^^^

Upvotes: 3

Related Questions