Doing the following query:
SELECT title FROM table ORDER BY title
gives me:
"Hello"
"Zebra"
Apple
Beta
Cactus
How would I ORDER BY the first alphabetical character, in order to get:
Apple
Beta
Cactus
"Hello"
"Zebra"
?
The MySQL ORDER BY Keyword The ORDER BY keyword is used to sort the result-set in ascending or descending order. The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.
Whereas if the telephone book were organized by first name then by last name, you'd find all the Johns together, then within the Johns, all the 'S' last names would be grouped together. So the order of columns in a multi-column index definitely matters. One type of query may need a certain column order for the index.
In MySQL, filesort is the catch-all algorithm for producing sorted results for ORDER-BY or GROUP-BY queries. MySQL has two algorithms for filesort, both the original and the modified algorithms are described in the user manual.
You will have to remove quotes before sorting data. You can easily remove them using TRIM
function in MySQL as:
SELECT title
FROM table
ORDER BY TRIM(BOTH '"' FROM title);
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