我查询sqlite数据库的某些表:
public Cursor showAllTables(){
String mySql = " SELECT name FROM sqlite_master " + " WHERE type='table' "
+ " AND name LIKE 'PR_%' ORDER BY name";
return ourDatabase.rawQuery(mySql, null);
}我得到了这个结果:
雪佛兰
我怎样才能在第一个字母是大写字母的情况下,单独订购清单呢?
发布于 2012-03-12 21:24:41
您需要将COLLATE NOCASE添加到查询的末尾:
public Cursor showAllTables(){
String mySql = " SELECT name FROM sqlite_master " + " WHERE type='table' "
+ " AND name LIKE 'PR_%' ORDER BY name COLLATE NOCASE";
return ourDatabase.rawQuery(mySql, null);
}或者您可以重新创建表并将COLLATE NOCASE添加到列定义中。
发布于 2012-03-12 21:25:07
你可以试试这个:
public Cursor showAllTables(){
String mySql = " SELECT name FROM sqlite_master " + " WHERE type='table' "
+ " AND name LIKE 'PR_%' ORDER BY lower(name)";
return ourDatabase.rawQuery(mySql, null);
}我只用较低的(名)换了名字。
https://stackoverflow.com/questions/9674969
复制相似问题