我查询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);
}
我得到了这个结果:
我如何能够独立于第一个字母是否为资本而订购列表?
答案 0 :(得分:2)
您需要在查询结尾添加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
添加到列定义中。
答案 1 :(得分:2)
你可以试试这个:
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);
}
我只更改了名字(名字)。