mysql - how to sort varchar numeric columns? -
this question has answer here:
- natural sort in mysql 19 answers
i write ... order by
column asc
column varchar
, sorts wrong
i want sorting numeric value datatype varchar how value this
1.2.840.113619.2.55.3.163578213.42.1355218116.691.1 1.2.840.113619.2.55.3.163578213.42.1355218116.691.10 1.2.840.113619.2.55.3.163578213.42.1355218116.691.100 1.2.840.113619.2.55.3.163578213.42.1355218116.691.101 1.2.840.113619.2.55.3.163578213.42.1355218116.691.2 1.2.840.113619.2.55.3.163578213.42.1355218116.691.20
but want in sequence last
1.2.840.113619.2.55.3.163578213.42.1355218116.691.1 1.2.840.113619.2.55.3.163578213.42.1355218116.691.2 1.2.840.113619.2.55.3.163578213.42.1355218116.691.10 1.2.840.113619.2.55.3.163578213.42.1355218116.691.20 1.2.840.113619.2.55.3.163578213.42.1355218116.691.100 1.2.840.113619.2.55.3.163578213.42.1355218116.691.101
and have string this
1.2.840.114257.0.10325113632288210457800001002296133400001 1.2.840.114257.0.10379710976288210457800000002296491200000 1.2.840.114257.0.10328923264288210457800000002296158400001
i want sort ...
for specific example, can do:
order length(col), col
if have other examples, might need "parse" values using substring_index()
.
Comments
Post a Comment