MySQL Order with decimals -


i've got problem mysql ordering. query:

select * versions order version desc

it lists of versions this:

25.0.1364.86 25.0.1364.124 23.0.1271.100 

however .124 higher .86.

how can fix it?

a small improvement query posted @peterm (with thanks!)

select * `versions` order 1*substring_index(version, '.', 1) asc,       1*substring_index(substring_index(version, '.', -3),'.', 1) asc,       1*substring_index(substring_index(version, '.', -2),'.', 1) asc,       1*substring_index(version, '.', -1) asc,      version asc # sort non-numeric strings 

i tested more complicated values, letters, numbers, dashes , points, versions can written in format.

| version | ----------- | a-b     | | a-c     | | ab      | | b       | | c       | | c.a     | | c.a.b   | | c.b     | | c.b.a   | | c.b.b   | | ca      | | 1.2     | | 1.2.1   | | 2.1.1   | | 2.1.2   | | 3       | | 10      | | 123     | 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -