I have an sqlite table in my game that keeps track of scores. How do I make one of the columns track scores in ascending order instead of descending order?
+2
A:
The order of the data in the table itself is irrelevant, it's how you order it when retrieving it via a query is what matters.
In that case, in your SQL select statement, you can add the clause ORDER BY "column_name" ASC
where column_name
is the column you want to order by.
Jasarien
2010-02-10 16:45:58
+1
A:
The order your scores are saved in database is not relevant - you can specify the order you need in SQL query:
@"SELECT * FROM scoretable order by score asc";
@"SELECT * FROM scoretable order by score desc";
Vladimir
2010-02-10 16:46:19
where in my code do i put these lines?
Steve
2010-02-10 16:58:58
You need to add the `order by score asc` part to wherever in your code you are accessing the scores. IE right now in your code, how are you accessing the list of scores? Add `order by score` to that SQL query.
David Oneill
2010-02-10 17:17:49
i got it. when i use desc, it works, but changing it to asc makes the scores not show up in the table....
Steve
2010-02-10 17:51:35