query to a SQLite DB in android
I have a table in DB called TABLE_3 which has several columns....and I wanna do a query to that table using conditions for two of its columns
KEY_SPEED>prefix
and KEY_USER_ID_=user_id
but I don't know how to write it...can someone help me with that...here is how my query looks with only one of the conditions....How should this look with 2 conditions?
public Cursor getViteze(int prefix,int user_id)
{
Cursor mCursor=db.query(TABLE_3, new String[]{KEY_ROWID_3,KEY_LONGITUDE,KEY_LATITUDE,
KEY_SPEED,KEY_TIME,KEY_USER_ID_},
KEY_SPEED + ">" + prefix,null,null,null,null);
return mCursor;
}
Thx!
UPDATE:
public Cursor getViteze(int prefix)
{
Cursor mCursor=db.query(TABLE_3, new String[]
{KEY_ROWID_3,KEY_LONGITUDE,KEY_LATITUDE, KEY_SPEED,KEY_TIME,KEY_USER_ID_},
KEY_SPEED + ">" + prefix +"开发者_运维问答 AND "+ KEY_USER_ID_ + "=" +
3,null,null,null,KEY_SPEED + " DESC");
return mCursor;
}
The condition argument is like WHERE clause in SQL, so you can concatenate your conditions with AND and OR, something like the following,
KEY_SPEED + " > " + prefix + " AND KEY_USER_ID_=user_id"
精彩评论