SQLite Query in non case sensitive alphabetical order [duplicate]
COLLATE
goes before the order direction:
db.rawQuery("SELECT " + catName
+ " FROM " +tableName
+" ORDER BY "+catName+" COLLATE NOCASE ASC;", null);
But you don't need the ASC
-- that's the default so you could just as well use:
db.rawQuery("SELECT "+ catName
+" FROM "+ tableName
+" ORDER BY "+ catName +" COLLATE NOCASE;", null);
add COLLATE NOCASE after orderBy String.
db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy + " COLLATE NOCASE ASC");
here, order by ASC or DESC depends on your need.
This should work too I think:
db.rawQuery("SELECT "+ catName
+" FROM "+ tableName
+" ORDER BY lower("+ catName +");", null);