I have this column called code that look like : 1-100-ETC-60,1-100-ETC-20,1-100-ETC-70
The last two characters are always going to start with either 6, 2 or 7.
If I do a ORDER BY SUBSTRING(code,13) ASC, or DESC it’s going to sort them in numerical order. Thought that’s not what I want (or the client want).
The correct sorting order should be : 6 then 2 then 7.
Just want to know if this is possible solely through the use of SQL query.
You can use MySQL’s
FIELD()function: