how to get a correct sequence in order by mysql?

0

It has a sequence of numbers 1 through 20 I would like to know if you can get the sequence of the correct number, for example:

1,2,3,4,5,6,7,8,9,10,11 ...

As this query select * from table order by asc number;

It looks like this:

1,10,11,12,13,14,15,16,17,18,19,2,20 ...

has a way to get the first sequence I showed above using the order by

I already tried to use a field for order by did not work

    
asked by anonymous 12.07.2016 / 19:52

2 answers

1

SELECT * FROM tabela ORDER BY CAST(coluna_numero AS unsigned) ASC

    
12.07.2016 / 20:00
1

There may be other ways to resolve this, more you can read as follows:

  

SELECT * FROM table ORDER BY LENGTH (id), id

    
12.07.2016 / 20:01