按字母顺序排序行

时间:2013-01-08 14:17:02

标签: android sqlite

以下是我从SQLite db获取数据的方法:

getReadableDatabase().rawQuery("SELECT _id, " + COLUMN_NAME_TITLE + " FROM " + TABLE_NAME + " ORDER BY " + COLUMN_NAME_TITLE + " COLLATE NOCASE ", null));

但即使我添加了 ASC ,我也永远无法解决我的问题。这就是我所拥有的:

enter image description here

我做错了吗?

2 个答案:

答案 0 :(得分:0)

你必须使用orderby和ASC(升序)按字母顺序对项目进行排序。

          getReadableDatabase().rawQuery("SELECT _id, " + COLUMN_NAME_TITLE + " FROM " + TABLE_NAME + " ORDER BY " + COLUMN_NAME_TITLE +"ASC"+" COLLATE NOCASE ", null))

答案 1 :(得分:0)

尝试使用LOWER功能:

"SELECT _id, " + COLUMN_NAME_TITLE + " FROM " + TABLE_NAME + " ORDER BY LOWER(" + COLUMN_NAME_TITLE + ")"