Reputation: 1465
I am retrieving items from a SQLite database and displaying them in a UITableview, I am using the following SQL command to get the information.
SELECT DISTINCT Name FROM Food
Everything works fine except I notice that uppercase items come sorted first, then lowercase items, which messes up the whole alphabetical setup that I am trying to accomplish. I have looked into various SQL commands, but I couldn't find anything that would change this. I am new to working with databases, so any advice would be welcomed.
Example of problem:
What I would like:
Upvotes: 0
Views: 598
Reputation: 43130
You can also use the built-in NOCASE function for case insensitive matching,
but it works only for ASCII characters.
SELECT DISTINCT Name
FROM Food
ORDER BY Name ASC COLLATE NOCASE
Upvotes: 1
Reputation: 47978
order by lowercase:
SELECT DISTINCT Name
FROM Food
ORDER BY lower(Name)
Upvotes: 1