I wanted to sort results returned from SQL query on the basis of Substring. I am using MYSQL as DB. I am trying to achieve two different results
Sample data
aaa ad aa
aaa ab
aaa ac
1) First i want to sort on the basis of second substring.
Result:
aaa ab
aaa ac
aaa ad aa
2) Second i want to sort on the basis of last substring.
Result:
aaa ad aa
aaa ab
aaa ac
How can i achieve these tasks.
Much appreciate your help.. Regards
Edit 1: Substrings can be of any length. Also for the second case i want sorting on the basis of last substring. Which means it can be on any position..