最近搜索

mysql中varchar字符串按照数字排序

浏览:466
管理员 2022-01-30 12:16


image.png



期望:按照L1,L2,L3…L10,L11…的顺序排序


解决:


方法1:select * from test order by score-0 asc;


方法2:select * from test order by cast(score as signed ) asc;


方法3:select * from test order by convert(score,signed) asc;


方法4(亲测有效):select * from test order by substr(score from 2)-0 asc;


image.png


联系站长

站长微信:xiaomao0055

站长QQ:14496453