All I want to do is grab the stuff in alphabetical order and ignore the capital letters.
db.rawQuery("SELECT " + catName + " FROM "+tableName+" ORDER BY "+catName+" ASC COLLATE NOCASE;", null);
This is the code I'm using above, but it always gives me an SQLite exception saying that COLLATE is a syntax error.
android.database.sqlite.SQLiteException: near "COLLATE": syntax error: , while compiling: SELECT Artist FROM testTable COLLATE NOCASE ASC
To be case insensitive on firstname , write this: select * from tbl where firstname='john' COLLATE NOCASE and lastname='doe' . It's specific to that one column, not the entire where clause.
The important point to be noted is that SQLite is case insensitive, i.e. the clauses GLOB and glob have the same meaning in SQLite statements.
SQLite LIKE examplesTo find the tracks whose names start with the Wild literal string, you use the percent sign % wildcard at the end of the pattern. To find the tracks whose names end with Wild word, you use % wildcard at the beginning of the pattern.
SQL Server is, by default, case insensitive; however, it is possible to create a case-sensitive SQL Server database and even to make specific table columns case sensitive.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With