Ver Mensaje Individual
  #4 (permalink)  
Antiguo 31/05/2005, 12:32
DjNelson
 
Fecha de Ingreso: julio-2003
Ubicación: España
Mensajes: 723
Antigüedad: 20 años, 9 meses
Puntos: 0
Qué SGBD usas?

Si usas mysql he encontrado un truquete:

Posted by Albert Vega on September 3 2004 11:17pm [Delete] [Edit]

Similar to the above, if you have numbers written in text or characters, and you want to sort them in ascending order and you don't want this:
mysql> select number from (table) order by number;

+--------+
| number |
+--------+
| 1 |
| 10 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
+--------+


Use this:
mysql> select number from (table) order by (number+0);

+--------+
| number |
+--------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
+--------+

The (field + 0 ) converts the text/character in the field into an integer.

Es decir, que le sumes 0 al campo para convertirlo en un número.

Saludos.
__________________
Solo nosotros podemos decidir qué hacer con el tiempo que se nos ha dado. (Gandalf)

Última edición por DjNelson; 31/05/2005 a las 12:40