Android的SQLiteDatabase查询排序顺序 [英] Android SQLiteDatabase query sorting order

查看:213
本文介绍了Android的SQLiteDatabase查询排序顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的数据库中的数据是这样的:

I have data in my database like this:

Alice
anderson
Beatrice
benny
Carmen
calzone

使用这个code:

Using this code:

mDb.query(DATABASE_NAMES_TABLE, new String[] { KEY_ROWID,
            KEY_NAME }, null, null,
            null, null, KEY_NAME+ " ASC");

或此code与过滤器是

or this code with the filter being "":

mDb.query(true, DATABASE_NAMES_TABLE, new String[] { KEY_ROWID,
        KEY_NAME }, KEY_NAME + " LIKE ?",
        new String[] { filter+"%" }, null, null, null,
        null);

据排序上面的数据是这样的:

It sorts the above data like this:

Alice
Beatrice
Carmen
anderson
benny
calzone

这是正常的行为呢?我如何得到它排序,上面的命令,所有的作为和B和C是一起的?谢谢你。

Is this normal behavior? How do I get it to sort to the above order where all the As and Bs and Cs are together? Thanks.

推荐答案

您可以通过添加指定区分大小写 COLLATE NOCASE ,无论是在你的订单BY 条款,或(preferably)当您在那个特定的列声明创建表本身。

You can specify case sensitivity by adding COLLATE NOCASE, either in your ORDER BY clause, or (preferably) when you create the table itself in your declaration of that particular column.

这篇关于Android的SQLiteDatabase查询排序顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆