SQLite - ORDER BY to sort [case insensitive]
How to sort case insensitive result in SQLite using ORDER BY
Let’s demonstrate via an example.
We have table abc
with one column character_test
:
character_test |
---|
A |
B |
C |
D |
a |
b |
c |
d |
If you sort the column character_test
SELECT
*
FROM
abc
ORDER BY
character_test ASC;
SQLite consider case sensitive characters and will return this result:
character_test |
---|
A |
B |
C |
D |
a |
b |
c |
d |
And you want to sort the records by alphabetical order and disregard the case sensitivity:
SELECT
*
FROM
abc
ORDER BY
character_test COLLATE NOCASE ASC;
The result now is:
character_test |
---|
A |
a |
B |
b |
C |
c |
D |
d |
Need a good GUI tool for SQLite? Check out TablePlus. It’s native, beautiful, and available for free.
Not on Mac? Download TablePlus for Windows.
On Linux? Download TablePlus for Linux
Need a quick edit on the go? Download TablePlus for iOS