开发者

Android sort sqlite query results ignoring case

开发者 https://www.devze.com 2023-02-09 12:14 出处:网络
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

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


ORDER BY column COLLATE NOCASE;

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


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.


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

LCASE or LOWER (Check documentation)

0

精彩评论

暂无评论...
验证码 换一张
取 消