SQLite查询以不区分大小写的字母顺序

这个问题在这里已经有了答案:

  • 如何使用SQL Order By语句对结果进行排序不区分大小写? 3个答案

  • COLLATE在订单方向之前:

    db.rawQuery("SELECT " + catName 
               + " FROM " +tableName 
            +" ORDER BY "+catName+" COLLATE NOCASE ASC;", null);
    

    但是你不需要ASC这是默认的,所以你可以使用:

    db.rawQuery("SELECT "+ catName 
                +" FROM "+ tableName 
            +" ORDER BY "+ catName +" COLLATE NOCASE;", null);
    

    在orderBy String之后添加COLLATE NOCASE。

    db.query(table,columns,selection,selectionArgs,groupBy,having,orderBy +“COLLATE NOCASE ASC”);

    这里,ASC或DESC的订单取决于您的需要。


    这应该也适用我认为:

    db.rawQuery("SELECT "+ catName 
            +" FROM "+ tableName 
        +" ORDER BY lower("+ catName +");", null);
    
    链接地址: http://www.djcxy.com/p/67467.html

    上一篇: SQLite Query in non case sensitive alphabetical order

    下一篇: Can I save images to Blobstore and save data to Datastore in one trip?