Reputation: 279
i m having the table like this
------------------------
Id | MergeId | name |
------------------------
1 | M1 | Riya |
2 | M2 | diya |
3 | M3 | tiya |
------------------------
Now i need to select table OrderBy Ascending MergeId (M1,M2,M3,M4.....)
Upvotes: 0
Views: 60
Reputation: 204746
You need to remove the M
and then cast the value to a number. You can use a mathematical operation for that to do it implicitly
select * from your_table
order by substring(mergeId, 2) * 1 asc
or do it explicitly with
order by cast(substring(mergeId, 2) as unsigned) asc
Upvotes: 1