i am using sqlite in android application. there is one table with some columns . ex:-
columns :- Id name url watched
watched has boolean values . When i query it returns a Cursor, in the Cursor i want all the records where "watched = false " to be shown first , followed by the records where "watched = true ".
How can i achieve this
You would use ORDER BY
so you can do something like this: SELECT * FROM TABLENAME ORDER BY WATCHED
then to switch it from true
or false
ordered first you can use DESC
or ASC
at the end. Your statement would be: SELECT * FROM TABLENAME ORDER BY WATCHED ASC
DESC
keyword means descending so in your case it would show true
first ASC
keyword means ascending which would show false
first
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.