You could try this:

ORDER BY
  SUBSTRING_INDEX(TheColumn,'.',1),
  SUBSTRING_INDEX(SUBSTRING_INDEX(TheColumn,'.',-2),'.',1)+0,
  SUBSTRING_INDEX(TheColumn,'.',-1)+0

It is quite slow though, If possible, I'd suggest splitting that one column
into 3 separate columns. You woudl save space (not decimal points to
specify, and the nubmers would be stored as numbers) and sorting it the way
you want would be much easier and faster.

Chris
-----Original Message-----
From: Agrin, Nathan [mailto:[EMAIL PROTECTED]
Sent: Friday, November 14, 2003 10:44 AM
To: [EMAIL PROTECTED]
Subject: Sorting question


I've seen this question posted in various forms on the web, but not in
such a way that I have found helpful.  I have a column of data in the
following format name.xx.yy where the x's and y's represent numbers.
When selected by mySQL, the column is sorted in an odd way, given by the
following example:

name.10.2
name.1058.5
name.205.3

Obviously, in our day to day thinking, the order should appear as:

name.10.2
name.205.3
name.1058.5

Does anyone know a way to resort this data so that when it is displayed
it is in common numerical order using a simple SQL statement?  The data
is being pulled from a mySQL database and being displayed in a php page.

Thank you,
Nate


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to