mysql - Sorting numbers string with letter -
i have strings such
70x100 cm 70x140 cm 70x70 cm 72x120 cm 70x130x70 cm 70x75x70 cm 72x72 cm
when want sort in order:
70x70 cm 70x75x70 cm 70x100 cm 70x130x70 cm 70x140 cm 72x72 cm 72x120 cm
this code:
order cast(cast(eaov.value decimal(3,0)) unsigned integer), eaov.value
any ideas?
a minor mod answer strawberry. changing 'cm' series of x0 ensure there 3 dimensions sort order
select * eaov order cast(substring_index(replace(eaov.value, ' cm', 'x0x0x0'), 'x', 1) unsigned integer), cast(substring_index(substring_index(replace(eaov.value, ' cm', 'x0x0x0'), 'x', 2), 'x', -1) unsigned integer), cast(substring_index(substring_index(replace(eaov.value, ' cm', 'x0x0x0'), 'x', 2), 'x', -1) unsigned integer)
performance not strong point.
Comments
Post a Comment