I tried the following and it seems to partially be working:
$query = "select * from mytable order by SUBSTRING_INDEX(myvariable,'-', 1) DESC";
The problem I am encountering is that it is sorting as follows:
22546-1
173521-1
130805-201
128812-100
124543
119075-1
118699-1
1186774-1
117881-101
As you can see the pattern is that it is sorting by the first 5 numbers. So it is sorting correctly if you just take into account the first 5 numbers. However I need it to sort by everything before the dash and it is not doing that.
Any ideas as to what could be wrong would be greatly appreciated.
Thanks in advance for your time and help!