MySQL Forums
Forum List  »  Newbie

Re: "Order By" on a text field
Posted by: Felix Geerinckx
Date: May 18, 2005 02:51PM

yann.luppo wrote:

> I have a table with a primary key field (idField) declared as varchar(64). I did so because most of
> the time the key stored is going to be a numeric but sometimes it can be a some kind of small
> Text.
>
> But now I'm facing some issues trying to order by "idField" asc.


SELECT idField FROM atable ORDER BY idField REGEXP "^[^0-9]", idField+0, idField

to get the text ones at the end.

Change the regular expression to "^[0-9]" if you want the text ones upfront.

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
May 18, 2005 01:54PM
Re: "Order By" on a text field
May 18, 2005 02:51PM


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.