dbTalk Databases Forums  

Order by alphanumeric

comp.databases.mysql comp.databases.mysql


Discuss Order by alphanumeric in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Asteras Amaliadas
 
Posts: n/a

Default Order by alphanumeric - 05-08-2008 , 02:21 AM






Hi.

I want to sort the following selection list:

A1
A10
A5
BA100
BA11
BA5

alphanumerically, so that the list is first ordered by the variable
length alphabetic prefix and then by the variable length numeric
suffix, ie:

A1
A5
A10
BA5
BA11
BA100

Any idea? Note that I cannot change the strings (ie A1 to A0001, etc).

Thanks

Reply With Quote
  #2  
Old   
Rik Wasmus
 
Posts: n/a

Default Re: Order by alphanumeric - 05-08-2008 , 03:09 AM






On Thu, 08 May 2008 09:21:06 +0200, Asteras Amaliadas <asteras (AT) gmail (DOT) com>
wrote:

Quote:
Hi.

I want to sort the following selection list:

A1
A10
A5
BA100
BA11
BA5

alphanumerically, so that the list is first ordered by the variable
length alphabetic prefix and then by the variable length numeric
suffix, ie:

A1
A5
A10
BA5
BA11
BA100

Any idea? Note that I cannot change the strings (ie A1 to A0001, etc).
You should be able to... If it's important 'BA' an '11' should even be in
a different column.

What will work, but will produce warnings, is REVERSE(), CAST to integer,
yet another REVERSE, get that string length, CAST the result to integer
again, and that's your number, and get the portion of the string minus the
number characters on the right you found out using the weird cast/reverse
scenario, and that's your 'BA' string.
--
Rik Wasmus


Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.