Android sort sqlite query results ignoring case

你离开我真会死。 提交于 2019-11-29 05:53:03

问题


just wondering if theres a way of sorting the results of a query ignoring case. Cause at the moment fields starting with an upper case letter are sorted and put on top of the list and fields starting with lower case letter are also sorted but are put after the upper case fields.

Thanks -- Mike


回答1:


ORDER BY column COLLATE NOCASE;

See http://www.sqlite.org/datatype3.html#collation




回答2:


On the Android you are given a collation function called LOCALIZED.

When you specify your column, do the following:

CREATE TABLE song(..., title TEXT COLLATE LOCALIZED ASC, ...)

It works great. If you have the Android source code, just do a search for "COLLATE" to see all sorts of examples.




回答3:


Convert all entries to lower case for example: select name from table order by LCASE(name)

LCASE or LOWER (Check documentation)



来源:https://stackoverflow.com/questions/4917545/android-sort-sqlite-query-results-ignoring-case

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!