If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Sorting Columns Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-29-04, 14:00
akrishmohan akrishmohan is offline
Registered User
 
Join Date: May 2002
Location: USA
Posts: 9
Sorting Columns Question

hi all

an Interesting question

I have a column which stores a versin number in this format

1.5.5.19
1.5.5.9
...
...

I want to be able to sort this text column in an ascending order. Unfortunately it gives me 1.5.5.19 followed by 1.5.5.9 which is not the case.

Please let me know ASAP

Krish+
Reply With Quote
  #2 (permalink)  
Old 06-29-04, 14:18
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
This is an age old question, caused mostly by the unstructured format of the version numbers.

The simple answer is to make each of the "units" in the version number zero filled to some arbitrary width, so that your numbers would become 01.05.05.09 or something like that. This makes the numbers sortable as strings.

Another solution would be to change the storage from character to some form of binary. This would allow the version numbers to be sorted arbitrarily.

You have to figure out what solution works best for your problem.

-PatP
Reply With Quote
  #3 (permalink)  
Old 06-30-04, 22:12
metroid metroid is offline
Registered User
 
Join Date: Jun 2004
Posts: 2
you can check the next tip also

http://dev.mysql.com/doc/mysql/en/Sorting_rows.html
on the comments sections is your answer
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On