I want to perform case-insensitive ORDER BY in MySQL. I have the data in my database like A, C, b, e, D etc
I'm getting the result as A, C, D, b, e
But, I want the result as A, b, C, D, e
How can I get that?
If you want case-insensitive distinct, you need to use UPPER() or LOWER().
MySQL by default will make the ORDER BY option in queries case sensitive. This means that rows with the same starting letters (but different case) may be ordered non-alphabetically.
SQL Server is, by default, case insensitive; however, it is possible to create a case-sensitive SQL Server database and even to make specific table columns case sensitive. The way to determine if a database or database object is to check its "COLLATION" property and look for "CI" or "CS" in the result.
Table names are stored in lowercase on disk and name comparisons are not case-sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases.
Choose a case-insensitive collation
select * from your_table
order by your_column COLLATE utf8_general_ci
That way indexes still work and the query is fast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With