mysql - Order column by the last letter in the records -


i have table named seat contains following records :

+----+------+ | id | seat | +----+------+ | 1  | 1a   | +----+------+ | 2  | 1b   | +----+------+ | 3  | 2a   |       +----+------+ | 4  | 2b   |   +----+------+ | 5  | 3a   |   +----+------+ | 6  | 3b   |   +----+------+ | 7  | 4a   |   +----+------+ | 8  | 4b   |   +----+------+ | 9  | 10a  |   +----+------+ | 10 | 10b  |   +----+------+ | 11 | 11a  |   +----+------+ | 12 | 11b  |   +----+------+ | 13 | 12a  |   +----+------+ | 14 | 12b  |   +----+------+ 

i want order result based on last character of second column seat table shows :

+----+------+ | id | seat | +----+------+ | 1  | 1a   | +----+------+ | 3  | 2a   |       +----+------+ | 5  | 3a   |   +----+------+ | 7  | 4a   |   +----+------+ | 9  | 10a  | +----+------+ | 11 | 11a  |   +----+------+ | 13 | 12a  |   +----+------+ | 2  | 1b   |   +----+------+ | 4  | 2b   | +----+------+ | 6  | 3b   |       +----+------+ | 8  | 4b   |   +----+------+ | 10 | 10b  |   +----+------+ | 12 | 11b  |   +----+------+ | 14 | 12b  |   +----+------+ 

how can achieve result? functions should use ?

at first, can use right order last value(i.e. sign) , cast whole string unsigned (i.e., in mysql, 11a converted 11):

order right(`seat`, 1), cast(`seat` unsigned) 

sqlfiddle


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -