我有这样的 table
------------------------
Id | MergeId | name |
------------------------
1 | M1 | Riya |
2 | M2 | diya |
3 | M3 | tiya |
------------------------
现在我需要选择表 OrderBy Ascending MergeId (M1,M2,M3,M4.....)
最佳答案
您需要删除M
,然后将值转换为数字。您可以使用数学运算来隐式执行此操作
select * from your_table
order by substring(mergeId, 2) * 1 asc
或者明确地使用
order by cast(substring(mergeId, 2) as unsigned) asc
关于mysql - 如何在MySQL中按混合字符串/整数列的升序排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25128289/