简体   繁体   中英

Android sqlite query to get tables with values greater than a value

I am using sqlite in my android app and it has (id, name, age) string tables.

I want the query to get names with age greater than 20.

I am using this query

private static final String TABLE_NAME = "Favorite";
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_AGE = "age";

SELECT * FROM TABLE_NAME WHERE age > 20

But i am getting wrong tables, there are few tables with age less than 20.

Your question is not clear to me. By the way, I think your query should be:

"SELECT * FROM " + TABLE_NAME + " WHERE " +  KEY_AGE + " > 20 ";

Edit

"SELECT * FROM " + TABLE_NAME + " WHERE cast(age as INTEGER) > 20 ";

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