Steve
Steve

Reputation: 15

iPhone sqlite desc vs asc?

How come in my code when i use @"select Score from tblMed order by Score desc limit 10" everything works fine, but when I change "desc" to "asc" the scores don't show up???

Upvotes: 1

Views: 1425

Answers (2)

OMG Ponies
OMG Ponies

Reputation: 332701

Because:

ORDER BY score ASC

...means that the lowest values will be at the top of the list - adding LIMIT 10 to the query will return the first 10 records with the lowest scores, so I imagine you have entries with score values of zero and/or null.

Upvotes: 1

Brandon
Brandon

Reputation: 70022

Do you have NULL scores in your records?

If you change the ordering to asc, then it would start with NULLs before selecting records with an actual value.

Upvotes: 1

Related Questions