Sqlite Query Less Than Or Greater Than Check
I want to use this: return mDb.query(DATABASE_TABLE, new String[] { KEY_ROWID, KEY_LEVEL }, KEY_LEVEL + '>= 3 AND ' + KEY_LEVEL + ' < 5', null, null, null, null); But inste
Solution 1:
Just do this :
String[] selectionArgs = { "5", "5" };
String[] columns = { KEY_ROWID, KEY_COLUMN3, KEY_COLUMN4 };
String selection = "KEY_COLUMN3 >= ? AND KEY_COLUMN4 < ?";
return mDb.query(DATABASE_TABLE, columns, selection, selectionArgs, null, null, null);
Solution 2:
For me just passing numerics in String format like @buzeeg offered didn't work.
PROBLEM: My task was to perform UPDATE
and in my case it should not have succeed, but as you may guess, when we use 1
as query arg, '1'>2
means true
:
UPDATEtableSET field =1WHERE ? >2
SOLUTION:CAST
helped me to solve it:
SELECT*FROM smth WHERECAST(? asinteger) >2
Post a Comment for "Sqlite Query Less Than Or Greater Than Check"