View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 10:30 AM
Luuk
 
Posts: n/a
Default Re: Greater than/Less than with numeric strings


"strawberry" <zac.carey@gmail.com> schreef in bericht
news:5b2f7a09-6681-4bc9-a7e4-7b7178e22b02@b1g2000pra.googlegroups.com...
> On Dec 13, 8:21 am, "pzal...@gmail.com" <pzal...@gmail.com> wrote:
>> Hi!
>> I have a query/view that is part of a larger program where I want to
>> compare 2 version numbers to determine which is the "higher" version.
>> Examples would be
>> 4.2.5a.sarge9
>> 4.2.5a.sarge10
>>
>> in most situations the < > symbols work great from mysql because from
>> sarge1 to sarge9 the alphanumeric comparison works fine. However, as
>> the example above shows, i need something that will indicate that
>> sarge10 is actually a higher version than sarge9 except because the
>> alphanumeric comparison sees 9 vs 1 it puts the 9 as the higher
>> version. Can anyone suggest a painless way to achieve my goal?
>>
>> thanks!
>> Pat

>
> This might work:
>
> SELECT *
> FROM `versions`
> ORDER BY version +0


i think
SELECT *
FROM `versions`
ORDER BY version +length(version)
will have more success...

but will also not be correct.... ;-(


Reply With Quote