MySQL Forums
Forum List  »  Newbie

Re: Sort by last word in field
Posted by: Chris Stubben
Date: July 20, 2005 09:50AM

Use the substring_index function to grab the last word in the field.


select name from tmp order by substring_index(name, ' ', -1);
+--------------+
| name |
+--------------+
| Betty Boop |
| Bob Jones |
| Kevin Smith |
+--------------+

Options: ReplyQuote


Subject
Written By
Posted
July 19, 2005 10:16AM
Re: Sort by last word in field
July 20, 2005 09:50AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.