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 instead of 5 I want it to check the next column where it finds greater than or equal to three.
So when I give an input of say 5, I want it to check for greater than or equal to 5 in column 3 but less than the value in the next column, column 4.
Original code taken from Sqlite query check - less than and greater than.
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);
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
:
UPDATE table SET field = 1 WHERE ? > 2
SOLUTION: CAST
helped me to solve it:
SELECT * FROM smth WHERE CAST(? as integer) > 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With