SQLite query less or more than validation

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 him to check the next column, where he found more than or equal to three.

So, when I give input 5, I want it to check greater than or equal to 5 in column 3, but less than the value in the next column, column 4.

The source code from Sqlite Query Validation is smaller and larger .

+4
source share
1 answer

Just do the following:

 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); 
+4
source

Source: https://habr.com/ru/post/1498489/


All Articles