Pardeep Kr
Pardeep Kr

Reputation: 497

How to get records based on one column in sqlite3 in android

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

Upvotes: 0

Views: 24

Answers (1)

Pztar
Pztar

Reputation: 4759

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 ASCat 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

Upvotes: 1

Related Questions