如何使用 SQL Order By 语句对不区分大小写的结果进行排序?

2021-12-08 00:00:00 sql sorting sqlite sql-order-by

我有一个 SQLite 数据库,我正在尝试按字母顺序对其进行排序.问题是,SQLite 在排序过程中似乎没有考虑 A=a,因此我得到这样的结果:

I have a SQLite database that I am trying to sort by Alphabetical order. The problem is, SQLite doesn't seem to consider A=a during sorting, thus I get results like this:

A乙C吨一种乙C克

我想得到:

A一种乙乙CCG

需要做哪些我不知道的特殊 SQL 事情?

What special SQL thing needs to be done that I don't know about?

SELECT * FROM NOTES ORDER BY title

推荐答案

你也可以ORDER BY TITLE COLLATE NOCASE.

Edit:如果需要指定ASCDESC,在NOCASE 后添加,如

If you need to specify ASC or DESC, add this after NOCASE like

ORDER BY TITLE COLLATE NOCASE ASC

ORDER BY TITLE COLLATE NOCASE DESC

相关文章