简体   繁体   中英

Sqlite query check - less than and greater than

return mDb.query(DATABASE_TABLE, new String[] { KEY_ROWID, 
KEY_LEVEL }, KEY_LEVEL + ">" + "=" + 3 + "<" + 5, null, null, null, null);

What am I doing wrong. It's returning all over above and equal to level 3 but not less than 5. I've tried && | and such.

KEY_LEVEL + ">" + "=" + 3 + "<" + 5

translates as

KEY_LEVEL + ">=3<5"

Use that instead:

KEY_LEVEL + ">= 3 AND " + KEY_LEVEL + " < 5"

Compare KEY_LEVEL to 3 and compare KEY_LEVEL to 5 with a conjunction of two expressions. I've never seen SQL use the && or || operators; use AND and OR.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM