Complejo mysql ORDENAR POR

Doing the following query:

SELECT title FROM table ORDER BY title

me da:

"Hello"
"Zebra"
Apple
Beta
Cactus

How would I ORDER BY the first alphabetical character, in order to get:

Apple
Beta
Cactus
"Hello"
"Zebra"

?

preguntado el 31 de julio de 12 a las 11:07

3 Respuestas

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);

Respondido 31 Jul 12, 11:07

...ORDER BY REPLACE(title, '"', '');

Respondido 31 Jul 12, 11:07

SELECT title FROM table ORDER BY TRIM(LEADING '"' FROM title)

Respondido 31 Jul 12, 11:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.