php - Ordering versions in not lexicographical order -


this question has answer here:

i need sort versions extract db query .

right , sort order follows :

1.1.0 1.10.2 1.2.3 1.4 

but wish were:

1.1.0 1.2.3 1.4 1.10.2  

how can this?

try this

select * tab order cast(substring_index(ver, '.', 1) unsigned ),        cast(substring_index(substring_index( ver , '.', 2 ),'.',-1) unsigned ) ,               cast(substring_index(ver, '.', -1) unsigned ) 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -