MySQL Forums
Forum List  »  Newbie

Re: Sorting a column
Posted by: Felix Geerinckx
Date: April 09, 2005 03:27AM

mailtome wrote:

> I have a varchar column say Issue with data as
> follow
>
> 900
> 1100
> update
> test
> 800
>
> Now I want to sort this column
>
> Can anyone tell me the correct way to sot this
> column

The correct way is to not mix numerical and text data in the same column. The ORDER BY sorting of a VARCHAR is alphabetical, not numerical.

But you could use

SELECT col FROM foo
ORDER BY col REGEXP "^[^0-9]", col+0, col

--
felix

Options: ReplyQuote


Subject
Written By
Posted
April 08, 2005 10:37PM
Re: Sorting a column
April 09, 2005 03:27AM
April 09, 2005 04:57AM
April 14, 2005 11:51PM
April 15, 2005 02:04AM


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.