我正在尝试进行查询,并通过字段对结果进行不区分大小写的分组。这是我尝试过的,但它不起作用。
分组后降低关键字不会产生任何影响。
"SELECT " + MediaStore.Audio.Media.ARTIST + ", count(LOWER(" + MediaStore.Audio.Media.ARTIST +
")) FROM " + PlaylistDB.TABLE_ALL_TRACKS + " GROUP BY LOWER(" + MediaStore.Audio.Media.ARTIST
+") HAVING " + MediaStore.Audio.Media.ARTIST
+ " LIKE ? ORDER BY "+ MediaStore.Audio.Media.ARTIST + " COLLATE NOCASE ASC";
我也试过了COLLATE NOCASE。也行不通。
"SELECT " + MediaStore.Audio.Media.ARTIST + ", count(LOWER(" + MediaStore.Audio.Media.ARTIST +
")) FROM " + PlaylistDB.TABLE_ALL_TRACKS + " GROUP BY LOWER(" + MediaStore.Audio.Media.ARTIST
+") HAVING " + MediaStore.Audio.Media.ARTIST
+ " LIKE ? ORDER BY "+ MediaStore.Audio.Media.ARTIST + " COLLATE NOCASE ASC";
有什么可以建议我进行不区分大小写的分组吗?
答案 0 :(得分:0)
我解决了这个问题。较低的关键字适用于组。但我的错误是一些领域最后还有额外的空间。所以我通过使用trim关键字修复它。下面的代码可以正常工作
"SELECT " + MediaStore.Audio.Media.ARTIST + ", count(LOWER(TRIM(" + MediaStore.Audio.Media.ARTIST +
"))) FROM " + PlaylistDB.TABLE_ALL_TRACKS + " GROUP BY LOWER(TRIM(" + MediaStore.Audio.Media.ARTIST
+")) HAVING " + MediaStore.Audio.Media.ARTIST
+ " LIKE ? ORDER BY "+ MediaStore.Audio.Media.ARTIST + " COLLATE NOCASE ASC";