Android排序sqlite查询结果忽略大小写
只是想知道是否有一种方法可以对忽略大小写的查询结果进行排序。因为目前以大写字母开头的字段被排序并放置在列表的顶部,而以小写字母开头的字段也被排序但被放置在大写字段之后。
谢谢 - 麦克风
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
按列排序 NOCASE;
请参阅http://www.sqlite.org/datatype3.html#整理
ORDER BY column COLLATE NOCASE;
See http://www.sqlite.org/datatype3.html#collation
在 Android 上,您有一个名为 LOCALIZED 的排序函数。
当您指定列时,请执行以下操作:
CREATE TABLE Song(..., title TEXT COLLATE LOCALIZED ASC, ...)
效果很好。如果您有 Android 源代码,只需搜索“COLLATE”即可查看各种示例。
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.
将所有条目转换为小写,例如:select name from table order by LCASE(name)
LCASE or LOWER (查看文档)
Convert all entries to lower case for example: select name from table order by LCASE(name)
LCASE or LOWER (Check documentation)