SQLite 查询不区分大小写字母顺序
我想做的就是按字母顺序抓取内容并忽略大写字母。
db.rawQuery("SELECT " + catName + " FROM "+tableName+" ORDER BY "+catName+" ASC COLLATE NOCASE;", null);
这是我上面使用的代码,但它总是给我一个 SQLite 异常,说 COLLATE 是语法错误。
android.database.sqlite.SQLiteException:靠近“COLLATE”:语法错误:,编译时:从 testTable COLLATE NOCASE ASC 中选择艺术家
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
COLLATE
位于订单方向之前:但是您不需要
ASC
——这是默认设置,因此您也可以使用:COLLATE
goes before the order direction:But you don't need the
ASC
-- that's the default so you could just as well use:在 orderBy String 之后添加
COLLATE NOCASE
。这里,按 ASC 或 DESC 顺序取决于您的需要。
add
COLLATE NOCASE
after orderBy String.here, order by ASC or DESC depends on your need.
我认为这也应该有效:
This should work too I think: