sql order by - Need a help for sort in mysql -
hi want sort table .the field contains numbers,alphabets , numbers alphabets ie, 1 2 1a 11a 6a b i want sort to, 1 1a 2 6a 11a b my code is, select * t order cast(st signed), st result is, b 1 1a 2 6a 11a i found code in url " http://www.mpopp.net/2006/06/sorting-of-numeric-values-mixed-with-alphanumeric-values/ " please me this required sort order, in presence of 0 in table; select * t order st regexp '^[[:alpha:]].*', st+0, st an sqlfiddle test with . as first sort criteria, sorts anything starts letter after doesn't. that's regexp does. as second sort criteria sorts numerical value string starts ( st+0 adds 0 numerical part string starts , returns int) as last resort, sorts string alphabetical ones in order.