mysql - sort data with special chars -
in column have kind of varchars.
home external +1 pd home +24 pd home +1 pd home set 1 pd home external +12 pd home 1 pd home external +2 pd home set +1 pd home external +24 pd home set pd
i'm trying sort them out in way:
(alphabetical , numerical order)
home 1 pd home +1 pd home +24 pd home external +1 pd home external +2 pd home external +12 pd home external +24 pd home set pd home set 1 pd home set +1 pd
my problem can have multiple names different names length, in case home have other.
tried query cast, abs can't out would.
thanks!
you have split column value extract string , number parts.
you can use substring_index function passing -1 , -2 indexes of last 2 space chars.
substring between last , previous last space number part, substring value start second last space text part.
so should add order text_part_calculated, number_part_calculated
Comments
Post a Comment