我的表是这样的
------------------------
Id | MergeId | name |
------------------------
1 | M1 | Riya |
2 | M2 | diya |
3 | M3 | tiya |
------------------------
现在我需要选择表orderderby升序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