Reputation: 4175
How would I go about ordering by the last three letters of a name?
For example:
Ashley
Julia
Belvet
ley > lia > vet
Also, how would I go about doing a secondary sort by ID if the last three letters are the same (Bobby, Robby...)?
Upvotes: 2
Views: 58
Reputation: 97130
For your first question:
ORDER BY SUBSTR(name, -3)
For your second question:
ORDER BY SUBSTR(name, -3), id
Upvotes: 3