Android Sqlite Query Where And Where
I need to return the ID value from the database where dan == table_column_one and where vrijeme == table_column_two. I don't know how to do this. public static int returnID(String
Solution 1:
In SQLiteDatabase.query() the selection comes in two parts. The where clause (a String
) and the whereArgs (an array of String
).
To add more than one condition to the where clause you can use AND
or OR
, just like &&
or ||
in Java.
A question mark in the where clause is bound to one of the Strings in the whereArgs array.
cursor = db.query(TABLE_NAME, newString[] { TABLE_COLUMN_ID, TABLE_COLUMN_ONE, TABLE_COLUMN_TWO },
TABLE_COLUMN_ONE + " LIKE ? AND " + TABLE_COLUMN_TWO + " LIKE ?",
newString[] {"%" + dan + "%", "%" + vrijeme + "%"},
null, null, null, null);
Post a Comment for "Android Sqlite Query Where And Where"